openrewrite / rewrite-spring

OpenRewrite recipes for Spring projects.
Apache License 2.0
238 stars 66 forks source link

[ERROR] Recipe validation error in org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5.recipeList[1] #175

Closed josemariavillar closed 2 years ago

josemariavillar commented 2 years ago

Good morning,

In the last released version (4.18.0) a validation error is occurring when executing the recipe UpgradeSpringBoot_2_5. As you can see in the attached traces:

https://github.com/openrewrite/rewrite-spring/blob/e3852db3a8e8e72ed846270ced6590ac8f2dcc19/src/main/resources/META-INF/rewrite/spring-boot2-upgrade-version.yml#L221

[INFO] --- rewrite-maven-plugin:4.21.0:dryRun (default-cli) @ test-project ---
[INFO] Using active recipe(s) [org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[ERROR] Recipe validation error in org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5.recipeList[1] (in jar:file:/C:/Users/x271091/.m2/repository/org/openrewrite/recipe/rewrite-spring/4.18.0/rewrite-spring-4.18.0.jar!/META-INF/
rewrite/spring-boot2-upgrade-version.yml): refers to a recipe that doesn't exist.
[ERROR] Recipe validation errors detected as part of one or more activeRecipe(s). Execution will continue regardless.
[INFO] Parsing Java main files...
[INFO] Parsing Java test files...
[INFO] Running recipe(s)...
[WARNING] Unable to download metadata org.springframework.boot:spring-boot-starter-web
[WARNING] Unable to download metadata org.springframework.boot:spring-boot-starter-parent
[WARNING] These recipes would make changes to pom.xml:
[WARNING]     org.openrewrite.maven.ExcludeDependency
[WARNING]     org.openrewrite.maven.ExcludeDependency
[WARNING]     org.openrewrite.maven.UpgradeParentVersion
[WARNING] These recipes would make changes to src\main\resources\config\bootstrap.yml:
[WARNING]     org.openrewrite.yaml.ChangePropertyKey
[WARNING] Patch file available:
[WARNING]     C:\test_project\target\site\rewrite\rewrite.patch
[WARNING] Run 'mvn rewrite:run' to apply the recipes.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:40 min
[INFO] Finished at: 2022-03-25T13:23:24+01:00
[INFO] ------------------------------------------------------------------------

The results obtained are not as expected due to the error that occurs, as can be seen in the POM file.

diff --git a/pom.xml b/pom.xml
index 3d4f8ec..8ea3562 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@ org.openrewrite.maven.ExcludeDependency, org.openrewrite.maven.ExcludeDependency, org.openrewrite.maven.UpgradeParentVersion
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
-       <version>2.3.7.RELEASE</version>
+       <version>2.4.13</version>
    </parent>

    <properties>
@@ -34,6 +34,16 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
+           <exclusions>
+               <exclusion>
+                   <groupId>junit</groupId>
+                   <artifactId>junit</artifactId>
+               </exclusion>
+               <exclusion>
+                   <groupId>org.junit.vintage</groupId>
+                   <artifactId>junit-vintage-engine</artifactId>
+               </exclusion>
+           </exclusions>
        </dependency>
    </dependencies>

I have tested with version 4.17.0 and it worked correctly, but with the latest version it does not work.

Attached is a test case where the problem can be reproduced: https://github.com/josemariavillar/test_project/tree/upgrade_spring_boot_2_5

Thank you very much for the excellent support you provide

Thanks & regards

pway99 commented 2 years ago

Good Morning @josemariavillar,

The recipe does not exist error was discovered yesterday and addressed in #174. I also updated rewrite-core so the invalid recipe name is part of the error message https://github.com/openrewrite/rewrite/issues/1499

I pulled your upgrade_spring_boot_2_5 branch, invoked rewrite, the result is different in that the spring-boot-starter-parent is upgraded to 2.5.10.

The unnecessary exclusions are a result of the RemoveExclusion recipes running before the ExcludeDependency recipes and are not related to the validation error.

Would you mind trying the latest snapshot versions to confirm?

Thanks and Kind Regards

Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pom.xml b/pom.xml
--- a/pom.xml   (revision dbd59207cf4653c29aca09d6dbfc19dc17da87bb)
+++ b/pom.xml   (date 1648231326884)
@@ -15,7 +15,7 @@
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
-       <version>2.3.7.RELEASE</version>
+       <version>2.5.10</version>
    </parent>

    <properties>
@@ -34,6 +34,16 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
+           <exclusions>
+               <exclusion>
+                   <groupId>junit</groupId>
+                   <artifactId>junit</artifactId>
+               </exclusion>
+               <exclusion>
+                   <groupId>org.junit.vintage</groupId>
+                   <artifactId>junit-vintage-engine</artifactId>
+               </exclusion>
+           </exclusions>
        </dependency>
    </dependencies>
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< com.test.project:test-project >--------------------
[INFO] Building Test Project 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> rewrite-maven-plugin:4.21.0:run (default-cli) > process-test-classes @ test-project >>>
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ test-project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ test-project ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ test-project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/pat/test-projects/josemariavillar/test_project/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ test-project ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< rewrite-maven-plugin:4.21.0:run (default-cli) < process-test-classes @ test-project <<<
[INFO] 
[INFO] 
[INFO] --- rewrite-maven-plugin:4.21.0:run (default-cli) @ test-project ---
[INFO] Using active recipe(s) [org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[ERROR] Recipe validation error in org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5.recipeList[1] (in jar:file:/Users/pat/.m2/repository/org/openrewrite/recipe/rewrite-spring/4.18.0/rewrite-spring-4.18.0.jar!/META-INF/rewrite/spring-boot2-upgrade-version.yml): refers to a recipe that doesn't exist.
[ERROR] Recipe validation errors detected as part of one or more activeRecipe(s). Execution will continue regardless.
[INFO] Parsing Java main files...
[INFO] Parsing Java test files...
[INFO] Running recipe(s)...
[WARNING] Changes have been made to pom.xml by:
[WARNING]     org.openrewrite.maven.ExcludeDependency
[WARNING]     org.openrewrite.maven.UpgradeParentVersion
[WARNING]     org.openrewrite.maven.ExcludeDependency
[WARNING] Changes have been made to src/main/resources/config/bootstrap.yml by:
[WARNING]     org.openrewrite.yaml.ChangePropertyKey
[WARNING] Please review and commit the results.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.097 s
[INFO] Finished at: 2022-03-25T09:12:24-07:00
[INFO] ------------------------------------------------------------------------
josemariavillar commented 2 years ago

Good morning,

I just tested with version 4.19.0-SNAPSHOT, as you mentioned and it worked correctly. I attach the result obtained from the test example:

<plugin>
    <groupId>org.openrewrite.maven</groupId>
    <artifactId>rewrite-maven-plugin</artifactId>
    <version>${rewrite-maven-plugin.version}</version>
    <configuration>
        <activeRecipes>
            <recipe>org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_5</recipe>
        </activeRecipes>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.openrewrite.recipe</groupId>
            <artifactId>rewrite-spring</artifactId>
            <version>4.19.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</plugin>
diff --git a/pom.xml b/pom.xml
index 3bf9a8d..1f6be7b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@ org.openrewrite.maven.ExcludeDependency, org.openrewrite.maven.ExcludeDependency, org.openrewrite.maven.UpgradeParentVersion
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
-       <version>2.3.7.RELEASE</version>
+       <version>2.5.11</version>
    </parent>

Thank you very much

pway99 commented 2 years ago

Thanks, Jose and Tim, Closing this issue in favor of https://github.com/openrewrite/rewrite/issues/1510