You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not (actively) maintained anymore, you might want to check out the Spotless Gradle plugin
Gradle Format plugin
The Gradle Format plugin enables you to format your Java sources. It operates in place and can be used for instance
before pushing changes to enforce a coding style. The formatting can be customized using a properties or XML file with
the keys defined in DefaultCodeFormatterConstants
from Eclipse. See src/test/resources/ for examples.
Eventually you should be able to export Eclipse settings to this file.
The plugin also enables you to sort imports.
Usage
To use the Format plugin, include in your build script:
The plugin JAR needs to be accessible in the classpath of your build script. It is directly available on
Gradle plugins.
Alternatively, you can download it from GitHub and deploy it to your local repository. The following code snippet shows an
example on how to get it and use it:
plugins {
id "com.github.youribonnaffe.gradle.format" version "1.5"
}
Tasks
The Format plugin defines the following tasks:
format: Format Java source code
Properties
The Format task defines the following properties:
configurationFile: The formatter configuration (File)
importsOrder: The import orders (List of strings)
importsOrderConfigurationFile: The import orders (a file using Eclipse format)
files: The files to format (FileCollection), defaults are Java sources from main and test SourceSets