diff --git a/src/main/resources/META-INF/rewrite/best-practices.yml b/src/main/resources/META-INF/rewrite/best-practices.yml new file mode 100644 index 00000000..77a1b80a --- /dev/null +++ b/src/main/resources/META-INF/rewrite/best-practices.yml @@ -0,0 +1,45 @@ +# +# Copyright 2024 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.spring.boot3.SpringBoot3BestPractices +displayName: Spring Boot 3.x best practices +description: Applies best practices to Spring Boot 3 applications. +tags: + - spring + - boot +recipeList: + - org.openrewrite.java.spring.boot2.SpringBoot2BestPractices + - org.openrewrite.java.migrate.UpgradeToJava21 # Allows for virtual threads + - org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 + - org.openrewrite.java.spring.boot3.EnableVirtualThreads + # Replace literals with constants and simplify MediaType parse calls + - org.openrewrite.java.spring.http.ReplaceStringLiteralsWithHttpHeadersConstants + - org.openrewrite.java.spring.http.ReplaceStringLiteralsWithMediaTypeConstants + - org.openrewrite.java.spring.http.SimplifyMediaTypeParseCalls + - org.openrewrite.java.spring.http.SimplifyWebTestClientCalls +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.spring.boot3.EnableVirtualThreads +displayName: Enable Virtual Threads on Java 21 +description: Set `spring.threads.virtual.enabled` to `true` in `application.properties` or `application.yml`. +preconditions: + - org.openrewrite.java.search.HasJavaVersion: + version: 21.X +recipeList: + - org.openrewrite.java.spring.AddSpringProperty: + property: spring.threads.virtual.enabled + value: true diff --git a/src/main/resources/META-INF/rewrite/spring-boot-32.yml b/src/main/resources/META-INF/rewrite/spring-boot-32.yml index 3becdbc3..2468b918 100644 --- a/src/main/resources/META-INF/rewrite/spring-boot-32.yml +++ b/src/main/resources/META-INF/rewrite/spring-boot-32.yml @@ -54,7 +54,6 @@ recipeList: onlyIfUsing: org.apache.commons.codec..* - org.openrewrite.java.spring.security6.UpgradeSpringSecurity_6_2 - org.openrewrite.java.spring.boot3.SpringBootProperties_3_2 - - org.openrewrite.java.spring.boot3.EnableVirtualThreads - org.openrewrite.java.spring.framework.UpgradeSpringFramework_6_1 - org.openrewrite.java.spring.cloud2023.UpgradeSpringCloud_2023 - org.openrewrite.java.ChangeType: @@ -79,19 +78,6 @@ recipeList: - org.openrewrite.hibernate.MigrateToHibernate64 - org.openrewrite.java.spring.boot3.RelocateLauncherClasses ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.spring.boot3.EnableVirtualThreads -displayName: Enable Virtual Threads on Java 21 -description: Set `spring.threads.virtual.enabled` to `true` in `application.properties` or `application.yml`. -preconditions: - - org.openrewrite.java.search.HasJavaVersion: - version: 21.X -recipeList: - - org.openrewrite.java.spring.AddSpringProperty: - property: spring.threads.virtual.enabled - value: true - --- type: specs.openrewrite.org/v1beta/recipe name: org.openrewrite.java.spring.boot3.RelocateLauncherClasses diff --git a/src/main/resources/META-INF/rewrite/spring-boot-33.yml b/src/main/resources/META-INF/rewrite/spring-boot-33.yml index 57d9d293..2358b3c4 100644 --- a/src/main/resources/META-INF/rewrite/spring-boot-33.yml +++ b/src/main/resources/META-INF/rewrite/spring-boot-33.yml @@ -61,21 +61,3 @@ recipeList: artifactId: "*" newVersion: 2.6.x - org.openrewrite.hibernate.MigrateToHibernate65 - ---- -type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.spring.boot3.SpringBoot3BestPractices -displayName: Spring Boot 3.x best practices -description: Applies best practices to Spring Boot 3 applications. -tags: - - spring - - boot -recipeList: - - org.openrewrite.java.spring.boot2.SpringBoot2BestPractices - - org.openrewrite.java.migrate.UpgradeToJava21 # Allows for virtual threads - - org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 - # Replace literals with constants and simplify MediaType parse calls - - org.openrewrite.java.spring.http.ReplaceStringLiteralsWithHttpHeadersConstants - - org.openrewrite.java.spring.http.ReplaceStringLiteralsWithMediaTypeConstants - - org.openrewrite.java.spring.http.SimplifyMediaTypeParseCalls - - org.openrewrite.java.spring.http.SimplifyWebTestClientCalls diff --git a/src/testWithSpringBoot_2_6/java/org/openrewrite/java/springdoc/MigrateSpringdocCommonTest.java b/src/testWithSpringBoot_2_6/java/org/openrewrite/java/springdoc/MigrateSpringdocCommonTest.java index 01427a62..63a60d5f 100644 --- a/src/testWithSpringBoot_2_6/java/org/openrewrite/java/springdoc/MigrateSpringdocCommonTest.java +++ b/src/testWithSpringBoot_2_6/java/org/openrewrite/java/springdoc/MigrateSpringdocCommonTest.java @@ -17,12 +17,11 @@ import org.junit.jupiter.api.Test; import org.openrewrite.DocumentExample; -import org.openrewrite.InMemoryExecutionContext; -import static org.openrewrite.java.Assertions.java; import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; -import org.openrewrite.test.TypeValidation; + +import static org.openrewrite.java.Assertions.java; class MigrateSpringdocCommonTest implements RewriteTest {