Skip to content

Commit d2432b8

Browse files
committed
Document Maven/Gradle
1 parent 13f0fbb commit d2432b8

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

Diff for: README.adoc

+88
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,91 @@
22

33
A project that uses https://docs.openrewrite.org/[OpenRewrite] to automatically fix the style of code to conform to https://github.com/spring-io/spring-javaformat[Spring Java Format].
44
The project will incrementally add automation to fix rules with the goal of eventually automating fixes for all fixes.
5+
6+
== Configuration
7+
8+
Spring Restyle is implemented using OpenRewrite.
9+
To use it in your projects, you can leverage the https://docs.openrewrite.org/reference/gradle-plugin-configuration[OpenRewrite Gradle plugin] and https://docs.openrewrite.org/reference/rewrite-maven-plugin[OpenRewrite Maven plugin.
10+
You then need to add the `io.spring.restyle:spring-restyle` jar to your project, and activate the `io.spring.Style` OpenRewrite style and the `io.spring.Format` format Recipe.
11+
Details can be found below.
12+
13+
=== Gradle
14+
15+
To use Spring Restyle with Gradle, you can use the https://docs.openrewrite.org/reference/gradle-plugin-configuration[OpenRewrite Gradle plugin].
16+
An outline of the configuration can be found below:
17+
18+
.build.gradle
19+
[source,groovy]
20+
----
21+
plugins {
22+
id "java"
23+
// replace with the latest version https://docs.openrewrite.org/reference/gradle-plugin-configuration
24+
id "org.openrewrite.rewrite" version"7.2.0"
25+
}
26+
27+
ext['restyle.inceptionYear'] = '2002'
28+
ext['restyle.projectRootPackage'] = 'org.springframework.security'
29+
30+
rewrite {
31+
activeRecipe('io.spring.Format')
32+
activeStyle('io.spring.Style')
33+
}
34+
35+
// Ensure a repository is declared that the rewrite core libraries can be resolved from
36+
repositories {
37+
mavenCentral()
38+
// If you want to use spring-restyle SNAPSHOTs you need to add the Spring SNAPSHOT repository
39+
maven { url 'https://repo.spring.io/snapshot'}
40+
}
41+
42+
dependencies {
43+
rewrite('io.spring.restyle:spring-restyle:0.0.1-SNAPSHOT')
44+
}
45+
----
46+
47+
Then you can invoke `./gradlew rewriteRun`
48+
49+
=== Maven
50+
51+
To use Spring Restyle with Gradle, you can use the https://docs.openrewrite.org/reference/rewrite-maven-plugin[OpenRewrite Maven plugin].
52+
An outline of the configuration can be found below:
53+
54+
.pom.xml
55+
[source,xml]
56+
----
57+
<project>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.openrewrite.maven</groupId>
62+
<artifactId>rewrite-maven-plugin</artifactId>
63+
<version>6.3.1</version>
64+
<configuration>
65+
<activeRecipes>
66+
<recipe>io.spring.Format</recipe>
67+
</activeRecipes>
68+
<activeStyles>
69+
<style>io.spring.Style</style>
70+
</activeStyles>
71+
</configuration>
72+
<dependencies>
73+
<dependency>
74+
<groupId>io.spring.restyle</groupId>
75+
<artifactId>spring-restyle</artifactId>
76+
<version>0.0.1-SNAPSHOT</version>
77+
</dependency>
78+
</dependencies>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
<repositories>
83+
<!-- if you are using a SNAPSHOT of spring-restyle you need to add the Spring SNAPSHOT repo -->
84+
<repository>
85+
<id>spring-snapshot</id>
86+
<url>https://repo.spring.io/snapshot</url>
87+
</repository>
88+
</repositories>
89+
</project>
90+
----
91+
92+
Then you can invoke `mvn rewrite:run`

0 commit comments

Comments
 (0)