plugins
section to apply the rewrite plugin to the project.--add-exports
. The are a few options for to setting explicit exports for packages used by rewrite's java parser.org.gradle.jvmargs
to include this content:./mvnw rewrite:discover
or ./gradlew rewriteDiscover
to see a listing of all the recipes available for execution. Initially this will list only the recipes built-in to OpenRewrite.org.openrewrite.java.format.AutoFormat
recipe. This recipe will format the source code in the project according to the styles specified in the rewrite.yml file, or according to Jetbrains IntelliJ's default Java style if no other style is specified.AutoFormat
activated we can now apply it to the project. Run:git diff
, or use your preferred IDE's diff viewer, to inspect the changes.org.openrewrite.java.ChangePackage
will move Java classes between package names you specify and update references and imports accordingly. To rename the org.springframework.samples.petclinic.vet
package to org.springframework.samples.petclinic.veterinary
, create a rewrite.yml file at the project root and give it these contents:com.yourorg.VetToVeterinary
. Now add it to the active recipe list:./mvnw rewrite:run
or ./gradlew rewriteRun
to perform the package relocation. Afterwards you'll see both that the sources in the vet package have been moved to the new directory, and references such as import statements have been updated accordingly../mvnw clean install
or ./gradlew build
. At this point you know how to configure and run any recipe included in rewrite itself.rewrite
dependency on rewrite-springorg.openrewrite.java.spring.boot2.SpringBoot2JUnit4to5Migration
recipe as active../mvnw rewrite:run
or ./gradlew rewriteRun
and observe that the project has been upgraded to Spring Boot 2 and the test classes are all updated to be JUnit 5 tests. If you're using Maven, the pom.xml will also have had the Spring dependencies updated, the Junit 4 dependency removed and Junit 5 dependencies added. OpenRewrite does not yet support automatic update of Gradle dependencies. Gradle users will have to manually make the corresponding changes.