[backport 19.04] Automated Java code formatting and verification #2695
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #2694 to
19.04
.Apply formatter-maven-plugin formatting to all projects.
Add the
net.revelc.code.formatter:formatter-maven-plugin
and configure it to be inherited by georchestra projects (no geoserver/geonetwork submodules).The plugin is configured to format only java source code files using the
.mvn/formatter.xml
eclipse format definition.This file can be directly imported from eclipse IDE and from IntelliJ IDEA's Eclipse Code Formatter plugin.
When compiling a project that includes the formatter-maven-plugin, the default action is to format the source code to adhere to the defined code style.
The other option is to instruct the plugin to check for correct formatting and fail the build.
This behavior is controlled by the fmt.action property, like in
mvn compile -Dfmt.action=format
or-Dfmt.action=validate
. By default a project build will run theformat
action, so nothing special needs to be done in order to ensure the proper format of the code other than making sure to run the build before committing/pushing to github.On a CI build server (Jenkins/Travis-CI), the
-Dfmt.action=validate
should be used, to ensure a committer did his/her due diligence before pushing to the upstream git repository, which is already the case for Travis-CI.Finally, the plugin can be disabled with the
-Dfmt.skip=true
maven property.