Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/java-version-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ recipeList:
groupId: org.apache.maven.plugins
artifactId: maven-compiler-plugin
newVersion: 3.6.2
addVersionIfMissing: true
- org.openrewrite.github.SetupJavaUpgradeJavaVersion:
minimumJavaMajorVersion: 11
- org.openrewrite.maven.UpgradePluginVersion:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/java-version-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ recipeList:
groupId: org.apache.maven.plugins
artifactId: maven-compiler-plugin
newVersion: 3.x
addVersionIfMissing: true
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-war-plugin
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/java-version-25.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ recipeList:
groupId: org.apache.maven.plugins
artifactId: maven-compiler-plugin
newVersion: 3.15.x
addVersionIfMissing: true
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-surefire-plugin
Expand Down
80 changes: 80 additions & 0 deletions src/test/java/org/openrewrite/java/migrate/Java8toJava11Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,86 @@ void needToJaxb2MavenPlugin() {
);
}

@Test
void compilerPluginVersionAddedWhenMissing() {
rewriteRun(
version(
mavenProject("project",
//language=xml
pomXml(
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
""",
spec -> spec.after(pomXml -> {
assertThat(pomXml).contains("<version>3.");
return pomXml;
})
)
),
8)
);
}

@Test
void compilerPluginVersionAddedAndReleaseSetForFullMigration() {
rewriteRun(
spec -> spec.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate")
.build()
.activateRecipes("org.openrewrite.java.migrate.Java8toJava11")),
version(
mavenProject("project",
//language=xml
pomXml(
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
""",
spec -> spec.after(pomXml -> {
assertThat(pomXml)
.contains("<release>11</release>")
.contains("<version>3.")
.doesNotContain("<source>")
.doesNotContain("<target>");
return pomXml;
})
)
),
8)
);
}

@Test
void noChangeOnCorrectJaxb2MavenPluginVersion() {
rewriteRun(
Expand Down
Loading