@@ -9,7 +9,7 @@ A set of plugins that can be applied to any Java project to provide a consistent
99The set currently consists of:
1010
1111* A source formatter that applies wrapping and whitespace conventions
12- * A checkstyle plugin that enforces consistency across a codebase
12+ * A Checkstyle plugin that enforces consistency across a codebase
1313
1414Since the aim of this project is to provide consistency, each plugin is not generally configurable.
1515You need to change your code to match the required conventions.
@@ -82,7 +82,7 @@ If you want to skip both, you can use `-Dspring-javaformat.skip=true`.
8282
8383
8484==== Checkstyle
85- To enforce checkstyle conventions, add the checkstyle plugin and include a dependency on `spring-javaformat-checkstyle`:
85+ To enforce Checkstyle conventions, add the Checkstyle plugin and include a dependency on `spring-javaformat-checkstyle`:
8686
8787[source,xml,indent=0,subs="normal"]
8888----
@@ -126,46 +126,49 @@ To enforce checkstyle conventions, add the checkstyle plugin and include a depen
126126
127127
128128=== Gradle
129+ A plugin is provided.
130+ To use it, first update `settings.gradle` to add Maven Central as a plugin repository:
129131
132+ [source,groovy,indent=0,subs="normal"]
133+ pluginManagement {
134+ repositories {
135+ gradlePluginPortal()
136+ mavenCentral()
137+ }
138+ }
130139
131-
132- ==== Source Formatting
133- For source formatting, add the `spring-javaformat-gradle-plugin` to your `build` plugins as follows:
140+ The plugin can then be added in the usual way in `build.gradle`:
134141
135142[source,groovy,indent=0,subs="normal"]
136143----
137- buildscript {
138- repositories {
139- mavenCentral()
140- }
141- dependencies {
142- classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:{release-version}")
143- }
144- }
145-
146- apply plugin: 'io.spring.javaformat'
144+ plugins {
145+ id "io.spring.javaformat" version "{release-version}""
146+ }
147147----
148148
149+ ==== Source Formatting
149150The plugin adds `format` and `checkFormat` tasks to your project.
150- The `checkFormat` task is automatically applied when running the standard Gradle `check` task.
151+ The `checkFormat` task is automatically executed when running the standard Gradle `check` task.
151152
152- In case you want to exclude a package from being checked, for example if you generate sources, you can do this by adding the following configuration :
153+ In case you want to exclude a package from being checked, for example if you generate sources, add configuration similar to the following:
153154
154155[source,groovy,indent=0,subs="normal"]
155156----
156157tasks.withType(io.spring.javaformat.gradle.tasks.CheckFormat) {
157- exclude "package/to/exclude"
158+ exclude "package/to/exclude"
158159}
159160----
160161
161162
162163
163164==== Checkstyle
164- To enforce checkstyle conventions, add the checkstyle plugin and include a dependency on `spring-javaformat-checkstyle`:
165+ To enforce Checkstyle conventions, add the ` checkstyle` plugin and include a dependency on `spring-javaformat-checkstyle`:
165166
166167[source,groovy,indent=0,subs="normal"]
167168----
168- apply plugin: 'checkstyle'
169+ plugins {
170+ id "checkstyle"
171+ }
169172
170173checkstyle {
171174 toolVersion = "{checkstyle-version}"
@@ -176,7 +179,7 @@ dependencies {
176179}
177180----
178181
179- Your `checkstyle.xml` file should look then like this:
182+ To use the Spring checks, your `checkstyle.xml` file should look like this:
180183
181184[source,xml,indent=0]
182185----
@@ -368,7 +371,7 @@ If you find you need whitespace inside your method, consider whether extracting
368371Try to add javadoc for each public method and constant.
369372Private methods shouldn't generally need javadoc, unless it provides a natural place to document unusual behavior.
370373
371- The checkstyle rules will enforce that all public classes have javadoc.
374+ The Checkstyle rules will enforce that all public classes have javadoc.
372375They will also ensure that `@author` tags are well formed.
373376
374377
0 commit comments