-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
93 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
= Spring Rewrite Commons | ||
:partials_dir: spring-rewrite-commons-docs/src/main/antora/modules/ROOT/pages/partials | ||
:project-version: 0.1.0-SNAPSHOTS | ||
|
||
[quote] | ||
____ | ||
Spring Rewrite Commons provides a set of components to parse a Java project to OpenRewrite LST and apply recipes outside a build tool plugin. | ||
____ | ||
|
||
== Get started | ||
|
||
=== Add Dependency | ||
|
||
**Maven** | ||
include::{partials_dir}/maven-dependency-snippet.adoc[] | ||
|
||
**Gradle** | ||
include::{partials_dir}/gradle-dependency-snippet.adoc[] | ||
|
||
=== Implement a Recipe Launcher | ||
|
||
include::{partials_dir}/example-application-code.adoc[] | ||
|
||
|
||
== Reference documentation | ||
|
||
Find the reference documentation link:{docs}[here]. | ||
|
||
== Contributing | ||
|
||
https://help.github.com/articles/creating-a-pull-request[Pull requests] are welcome. Note, that we expect everyone to follow the https://github.com/spring-projects/.github/blob/main/CODE_OF_CONDUCT.md[code of conduct]. | ||
|
||
== License | ||
Spring Rewrite Commons is Open Source software released under the | ||
https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...-docs/src/main/antora/modules/ROOT/pages/partials/example-application-code.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[source,java] | ||
.... | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
@Component | ||
public class MyMigrationApplication { | ||
@Autowired <1> | ||
private RewriteProjectParser parser; | ||
@Autowired | ||
private RewriteRecipeDiscovery discovery; <3> | ||
@Autowired | ||
private ProjectResourceSetFactory resourceSetFactory; <4> | ||
@Autowired | ||
private ProjectResourceSetSerializer serializer; <5> | ||
public void migrateToBoot3_1() { | ||
Path baseDir = ... <2> | ||
String recipeName = "org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1"; | ||
Recipe boot3Upgrade = discover.getByName(recipeName); <3> | ||
RewriteParsingResult result = parser.parse(baseDir); <4> | ||
List<SourceFile> lst = result.sourceFiles(); <5> | ||
ProjectResourceSet resourceSet = resourceSetFactory.create(baseDir, lst); <6> | ||
resourceSet.apply(boot3Upgrade); <7> | ||
serializer.writeChanges(resourceSet); <8> | ||
} | ||
} | ||
.... | ||
<1> All components are Spring beans and can be injected as such. | ||
<2> The path of the project that should be migrated. | ||
<3> `RewriteRecipeDiscovery` is used to discover an OpenRewrite recipe by name. | ||
<4> `RewriteProjectParser` parses a given project to OpenRewrite LST. | ||
<5> The result contains the list of ``SourceFile``s (the LST). | ||
<6> `ProjectResourceSetFactory` can be used to create a `ProjectResourceSet`. | ||
<7> The recipe is applied to the `ProjectResourceSet` which wraps the LST. | ||
<8> `ProjectResourceSetSerializer` is used to serialize the changes to disk. |
4 changes: 4 additions & 0 deletions
4
...docs/src/main/antora/modules/ROOT/pages/partials/gradle-dependency-snippet.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[source,groovy,indent=0,subs="verbatim,quotes,attributes",role="secondary"s] | ||
---- | ||
compile 'org.springframework.rewrite:spring-rewrite-commons:{projectVersion}' | ||
---- |
8 changes: 8 additions & 0 deletions
8
...-docs/src/main/antora/modules/ROOT/pages/partials/maven-dependency-snippet.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[source,xml,indent=0,subs="verbatim,quotes,attributes",role="primary"] | ||
---- | ||
<dependency> | ||
<groupId>org.springframwork.rewrite</groupId> | ||
<artifactId>spring-rewrite-commons</artifactId> | ||
<version>{project-version}</version> | ||
</dependency> | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters