diff --git a/src/main/resources/META-INF/rewrite/java-version-11.yml b/src/main/resources/META-INF/rewrite/java-version-11.yml new file mode 100644 index 0000000000..0e3efea673 --- /dev/null +++ b/src/main/resources/META-INF/rewrite/java-version-11.yml @@ -0,0 +1,33 @@ +# +# Copyright 2022 the original author or authors. +#
+# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +#
+# https://www.apache.org/licenses/LICENSE-2.0 +#
+# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.migrate.JavaVersion11 +displayName: Change Maven Java version property values to 11 +description: Change maven.compiler.source and maven.compiler.target values to 11. +recipeList: + - org.openrewrite.maven.ChangePropertyValue: + key: java.version + newValue: 11 + addIfMissing: false + - org.openrewrite.maven.ChangePropertyValue: + key: maven.compiler.source + newValue: 11 + addIfMissing: false + - org.openrewrite.maven.ChangePropertyValue: + key: maven.compiler.target + newValue: 11 + addIfMissing: false diff --git a/src/main/resources/META-INF/rewrite/java8-to-java11.yml b/src/main/resources/META-INF/rewrite/java8-to-java11.yml index bc772c0209..13a6437d74 100644 --- a/src/main/resources/META-INF/rewrite/java8-to-java11.yml +++ b/src/main/resources/META-INF/rewrite/java8-to-java11.yml @@ -45,3 +45,4 @@ recipeList: - org.openrewrite.java.migrate.javax.JavaxXmlStreamAPIs - org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion - org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoMavenPluginVersion + - org.openrewrite.java.migrate.JavaVersion11 diff --git a/src/test/kotlin/org/openrewrite/java/migrate/JavaVersion11Test.kt b/src/test/kotlin/org/openrewrite/java/migrate/JavaVersion11Test.kt new file mode 100644 index 0000000000..d4bf29e25a --- /dev/null +++ b/src/test/kotlin/org/openrewrite/java/migrate/JavaVersion11Test.kt @@ -0,0 +1,91 @@ +/* + * Copyright 2022 the original author or authors. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * https://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openrewrite.java.migrate
+
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.Test
+import org.openrewrite.Recipe
+import org.openrewrite.config.Environment
+import org.openrewrite.maven.MavenRecipeTest
+
+class JavaVersion11Test : MavenRecipeTest {
+ override val recipe: Recipe = Environment.builder()
+ .scanRuntimeClasspath("org.openrewrite.java.migrate")
+ .build()
+ .activateRecipes("org.openrewrite.java.migrate.JavaVersion11")
+
+ @Test
+ fun changeJavaVersion() = assertChanged(
+ before = """
+