Style and formatting
Each project contains Eclipse configuration for code formatting and templates. This configuration goes a long way to ensuring that the correct code style is used and is largely based upon Oracle's code conventions for Java.
Whenever the master branch is built by the CI infrastructure, code style is policed by Sonar. To have Sonar check code style (and many other things) without the code having to be in the master branch, the Sonar plugin for Eclipse should be used.
Any new projects that are created must have this configuration added to it. The configuration is captured in two files in the project's .settings directory: org.eclipse.jdt.core.prefs
and org.eclipse.jdt.ui.prefs
. To add the configuration to a new project, copy these two files from an existing project into the new project.
The files are listed in the repository's .gitignore
file, but when a new project is being created they must be added to Git's index. To do so, add them with the -f
argument:
git add -f new-project/.settings/org.eclipse.jdt.*
git status
should then list the two files as changes to be committed:
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: new-project/.settings/org.eclipse.jdt.core.prefs
# new file: new-project/.settings/org.eclipse.jdt.ui.prefs