Skip to content

Commit e75d8ea

Browse files
committed
Switch to spring-javaformat plugin
Use `spring-javaformat` to format and check code. Code formatting can now be applied using the `spring-javaformat-maven-plugin` from the command line. Existing checkstyle rules have also been replaced and the CONTRIBUTING.adoc file has been updated. Closes spring-projectsgh-13255
1 parent e69296d commit e75d8ea

File tree

9 files changed

+117
-1089
lines changed

9 files changed

+117
-1089
lines changed

CONTRIBUTING.adoc

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ given the ability to merge pull requests.
4747
None of these is essential for a pull request, but they will all help. They can also be
4848
added after the original pull request but before a merge.
4949

50-
* Use the Spring Framework code format conventions. If you use Eclipse and you follow
51-
the '`Importing into eclipse`' instructions below you should get project specific
52-
formatting automatically. You can also import formatter settings using the
53-
`eclipse-code-formatter.xml` file from the `eclipse` folder. If using IntelliJ IDEA, you
54-
can use the http://plugins.jetbrains.com/plugin/6546[Eclipse Code Formatter Plugin]
55-
to import the same file.
50+
* We use the https://github.com/spring-io/spring-javaformat/[Spring JavaFormat] project
51+
to apply code formatting conventions. If you use Eclipse and you follow the '`Importing
52+
into eclipse`' instructions below you should get project specific formatting
53+
automatically. You can also install the https://github.com/spring-io/spring-javaformat/#intellij-idea[Spring JavaFormat IntelliJ Plugin]
54+
or format the code from the Maven build by running
55+
`./mvnw io.spring.javaformat:spring-javaformat-maven-plugin:apply`.
56+
* The build includes checkstyle rules for many of our code conventions. Run
57+
`./mvnw validate` if you want to check you changes are compliant.
5658
* Make sure all new `.java` files to have a simple Javadoc class comment with at least an
5759
`@author` tag identifying you, and preferably at least a paragraph on what the class is
5860
for.
@@ -80,13 +82,15 @@ should also work without issue.
8082

8183

8284
=== Building from Source
83-
To build the source you will need to install
84-
http://maven.apache.org/run-maven/index.html[Apache Maven] v3.2.3 or above and JDK 1.8.
85+
Spring Boot source can be build from the command line using
86+
http://maven.apache.org/run-maven/index.html[Apache Maven] on JDK 1.8 or above.
87+
We include '`Maven Wrapper`' scripts (`./mvnw` or `mvnw.bat`) that you can run rather
88+
than needing to install Maven locally.
8589

8690

8791

8892
==== Default Build
89-
The project can be built from the root directory using the standard maven command:
93+
The project can be built from the root directory using the standard Maven command:
9094

9195
[indent=0]
9296
----
@@ -151,9 +155,9 @@ to Maven by setting a `MAVEN_OPTS` environment variable with the value
151155

152156

153157
=== Importing into Eclipse
154-
You can import the Spring Boot code into any Eclipse Mars based distribution. The easiest
158+
You can import the Spring Boot code into any Eclipse Oxygen based distribution. The easiest
155159
way to setup a new environment is to use the Eclipse Installer with the provided
156-
`.setup` file.
160+
`.setup` file (in the `/eclipse` folder).
157161

158162

159163
==== Using the Eclipse Installer
@@ -182,24 +186,21 @@ easier to navigate.
182186

183187

184188
==== Manual Installation with M2Eclipse
185-
If you prefer to install Eclipse yourself we recommend that you use the
189+
If you prefer to install Eclipse yourself you should use the
186190
http://eclipse.org/m2e/[M2Eclipse] eclipse plugin. If you don't already have m2eclipse
187191
installed it is available from the "Eclipse marketplace".
188192

189193
Spring Boot includes project specific source formatting settings, in order to have these
190-
work with m2eclipse, we provide additional Eclipse plugins that you can install:
194+
work with m2eclipse, we provide an additional Eclipse plugin that you can install:
195+
191196

192-
===== Install the m2eclipse-maveneclipse plugin
193-
* Select "`Help`" -> "`Install New Software`".
194-
* Add `https://dl.bintray.com/philwebb/m2eclipse-maveneclipse` as a site.
195-
* Install "Maven Integration for the maven-eclipse-plugin"
196197

197198
===== Install the Spring Formatter plugin
198199
* Select "`Help`" -> "`Install New Software`".
199-
* Add `https://dl.bintray.com/philwebb/spring-eclipse-code-formatter/` as a site.
200-
* Install "Spring Code Formatter"
200+
* Add `https://dl.bintray.com/spring/javaformat-eclipse/` as a site.
201+
* Install "Spring Java Format"
201202

202-
NOTE: These plugins are optional. Projects can be imported without the plugins, your code
203+
NOTE: The plugin is optional. Projects can be imported without the plugins, your code
203204
changes just won't be automatically formatted.
204205

205206
With the requisite eclipse plugins installed you can select
@@ -208,28 +209,14 @@ need to import the root `spring-boot` pom and the `spring-boot-samples` pom sepa
208209

209210

210211

211-
==== Importing into Eclipse without M2Eclipse
212-
If you prefer not to use m2eclipse you can generate eclipse project metadata using the
213-
following command:
214-
215-
[indent=0]
216-
----
217-
$ ./mvnw eclipse:eclipse
218-
----
219-
220-
The generated eclipse projects can be imported by selecting `import existing projects`
221-
from the `file` menu.
222-
223-
224-
225212
=== Importing into Other IDEs
226213
Maven is well supported by most Java IDEs. Refer to your vendor documentation.
227214

228215

229216

230217
== Integration Tests
231218
The sample applications are used as integration tests during the build (when you
232-
`mvn install`). Due to the fact that they make use of the `spring-boot-maven-plugin`
219+
`./mvnw install`). Due to the fact that they make use of the `spring-boot-maven-plugin`
233220
they cannot be called directly, and so instead are launched via the
234221
`maven-invoker-plugin`. If you encounter build failures running the integration tests,
235222
check the `build.log` file in the appropriate sample directory.

0 commit comments

Comments
 (0)