Shared settings for Java projects using Eclipse JDT.
There are no dependencies for this project. It is a standalone project that does not depend on any other jars.
There are no modules declared in this project.
JDT Settings
Resource bundle which contains settings for Eclipse JDT. Use this bundle (or a fork of it) to set specific settings for a single project without changing workspace settings. Take a look at the usage guide to see how this bundle can be used to automatically set up a project in Eclipse.
Settings
Currently the following settings will be set:
Compiler
General
JDK Compliance
Setting |
Value |
Compiler compliance level |
1.8 |
Classfile Generation
Setting |
Value |
Add variable attributes to generated class files (used by the debugger) |
true |
Add line number attributes to generated class files (used by the debugger) |
true |
Add source file name to generated class file (used by the debugger) |
true |
Preserve unused (never read) local variables |
true |
Store information about method parameters (useable via reflection) |
true |
Building
General
Setting |
Value |
Maximum number of problems reported per compilation unit |
100 |
Enable use of exclusion patterns in source folders |
true |
Enable use of multiple output locations for source folders |
true |
Build path problems
Setting |
Value |
About build when build path errors occur |
true |
Incomplete build path |
Error |
Circular dependencies |
Error |
Incompatible required binaries |
Error |
Output location overlaps source location |
Error |
No strictly compatible JRE for execution environment available |
Error |
Output folder
Setting |
Value |
Duplicated resources |
Error |
Scrub output folders when cleaning projects |
true |
Rebuild class files modified by others |
false |
Filtered resources |
|
Errors/Warnings
Code style
Setting |
Value |
Non-static access to static member |
Error |
Indirect access to static member |
Error |
Unqualified access to instance field |
Ignore |
Access to a non-accessible member of an enclosing type |
Error |
Parameter assignment |
Error |
Non-externalized strings (missing/unused $NON-NLS$ tag) |
Error |
Undocumented empty block |
Error |
Resource not managed via try-with-resource (1.7 or higher) |
Error |
Method with a constructor name |
Error |
Method can be static |
Error |
Method can potentially be static |
Error |
Potential programming problems
Setting |
Value |
Comparing identical values (‘x == x’) |
Error |
Assignment has no effect (e.g. ‘x = x’) |
Error |
Possible accidental boolean assignment (e.g. ‘if (a = b)’) |
Error |
Boxing and unboxing conversions |
Error |
Using a char array in string concatenation |
Error |
Inexact type match for vararg arguments |
Error |
Empty statement |
Error |
Unused object allocation |
Error |
Incomplete ‘switch’ cases on enum |
Error |
Signal even if ‘default’ case exists |
false |
‘switch’ is missing ‘default’ case |
Error |
‘switch’ case fall-through |
Error |
Hidden catch block |
Error |
‘finally’ does not complete normally |
Error |
Dead code (e.g. ‘if (false)’) |
Error |
Resource leak |
Error |
Potential resource leak |
Error |
Serializable class without serialVersionUID |
Error |
Missing synchronized modifier on inherited method |
Error |
Class overrides ‘equals()’ but not ‘hashCode()’ |
Error |
Name shadowing and conflicts
Setting |
Value |
Field declaration hides another field or variable |
Error |
Local variable declaration hides another field or variable |
Error |
Include constructor or setter method parameters |
false |
Type parameter hides another type |
Error |
Method does not override package visible method |
Error |
Interface method conflicts with protected ‘Object’ method |
Error |
Deprecated and restricted API
Setting |
Value |
Deprecated API |
Error |
Signal use of deprecated API inside deprecated code |
true |
Signal overriding or implementing deprecated method |
true |
Forbidden reference (access rules) |
Error |
Discouraged reference (access rules) |
Error |
Unnecessary code
Setting |
Value |
Value of local variable is not used |
Error |
Value of parameter is not used |
Error |
Ignore in overriding and implementing methods |
true |
Unused type parameter |
Error |
Ignore unused parameters documented with ‘@param’ tag |
true |
Unused import |
Error |
Unused private member |
Error |
Unnecessary ‘else’ statement |
Error |
Unnecessary cast of ‘instanceof’ operation |
Error |
Unnecessary declaration of thrown exception |
Error |
Ignore in overriding and implementing methods |
true |
Ignore exceptions documented with ‘@throws’ or ‘@exception’ tags |
true |
Ignore ‘Exception’ and ‘Throwable’ |
true |
Unused ‘break’ or ‘continue’ label |
Error |
Redundant super interface |
Error |
Generic types
Setting |
Value |
Unchecked generic type operation |
Error |
Usage of raw type |
Error |
Generic type parameter declared with a final type bound |
Error |
Redundant type arguments (1.7 or higher) |
Error |
Ignore unavoidable generic type problems due to raw APIs |
false |
Annotations
Setting |
Value |
Missing ‘@Override’ annotation |
Error |
Include implementations of interface methods (1.6 or higher) |
true |
Missing ‘@Deprecated’ annotation |
Error |
Annotation is used as super interface |
Error |
Unhandled token in ‘@SuppressWarnings’ |
Error |
Enable ‘@SuppressWarnings’ annotation |
true |
Unused ‘@SuppressWarnings’ token |
Error |
Suppress optional errors with ‘@SuppressWarnings’ |
true |
Null analysis
Setting |
Value |
Null pointer access |
Error |
Potential null pointer access |
Error |
Redundant null check |
Error |
Include ‘assert’ in null analysis |
true |
Enable annotation-based null-analysis |
true |
Violation of null specification |
Error |
Conflict between null annotations and null inference |
Error |
Unchecked conversion from non-annotated type to @NonNull type |
Error |
Redundant null annotation |
Error |
‘@NonNull’ parameter not annotated in overriding method |
Error |
Missing ‘@NonNullByDefault’ annotation on package |
Warning |
Use default annotations for null specifications |
true |
‘Nullable’ annotation |
org.eclipse.jdt.annotation.Nullable |
‘NonNull’ annotation |
org.eclipse.jdt.annotation.NonNull |
‘NonNullByDefault’ annotation |
org.eclipse.jdt.annotation.NonNullByDefault |
Inherit null annotations |
true |
Enable syntactic null analysis for fields |
true |
Javadoc
Setting |
Value |
Process Javadoc comments |
true |
Malformed Javadoc comments |
Error |
Only consider members as visible as |
Public |
Validate tag arguments (@param, @throws, @exception, @see, @link) |
true |
Report non visible references |
true |
Report deprecated references |
true |
Missing tag descriptions |
Validate all standard tags |
Missing Javadoc tags |
Error |
Only consider members as visible as |
Public |
Ignore in overriding and implementing methods |
true |
Ignore method type parameters |
true |
Missing Javadoc comments |
Error |
Only consider members as visible as |
Public |
Ignore in overriding and implementing methods |
true |
Resource
Setting |
Value |
Text file encoding |
Other (UTF-8) |
New text file line delimiter |
Inherited from container (Unix) |
Code Style
General
Setting |
Value |
Prefix convention for names |
|
Suffix convention for names |
|
Qualify all generated field access with ‘this.’ |
false |
Use ‘is’ prefix for getters that return boolean |
true |
Add ‘@Override’ annotation for new overriding methods |
true |
Exception variable name in catch blocks |
exception |
Clean Up
Code Organizing
Formatter
Setting |
Value |
Format source code |
true |
Remove trailing whitespace |
true |
All lines |
true |
Correct indentation |
true |
Imports
Setting |
Value |
Organize imports |
true |
Members
Setting |
Value |
Sort members |
false |
Code Style
Control statements
Setting |
Value |
Use blocks in if/while/for/do statements |
Always |
Convert ‘for’ loops to enhanced |
true |
Expressions
Setting |
Value |
Use parentheses in expressions |
Only if necessary |
Variable declarations
Setting |
Value |
Use modifier ‘final’ where possible |
true |
Private fields |
true |
Parameter |
true |
Local variables |
true |
Functional interface instances
Setting |
Value |
Convert functional interface instances |
true |
Use lambda where possible |
true |
Member Accesses
Non static accesses
Setting |
Value |
Use ‘this’ qualifier for field accesses |
Only if necessary |
Use ‘this’ qualifier for method accesses |
Only if necessary |
Static accesses
Setting |
Value |
Use declaring class as qualifier |
true |
Qualify field accesses |
false |
Qualify method accesses |
false |
Change all accesses through subtypes |
true |
Change all accesses through instances |
true |
Missing Code
Annotations
Setting |
Value |
Add missing Annotations |
true |
‘@Override’ |
true |
Implementations of interface methods (1.6 or higher) |
true |
‘@Deprecated’ |
true |
Potential programming problems
Setting |
Value |
Add serial version ID |
Generated |
Unimplemented code
Setting |
Value |
Add unimplemented methods |
true |
Unnecessary Code
Unused code
Setting |
Value |
Remove unused imports |
true |
Remove unused private members |
true |
Types |
true |
Constructors |
true |
Fields |
true |
Methods |
true |
Remove unused local variables |
true |
Unnecessary code
Setting |
Value |
Remove unnecessary casts |
true |
Remove unnecessary ‘$NON-NLS$’ tags |
true |
Formatter
Indentation
General settings
Setting |
Value |
Tab policy |
Spaces only |
Indentation size |
4 |
Tab size |
4 |
Alignment of fields in class declarations
Setting |
Value |
Align fields in columns |
true |
Indent
Setting |
Value |
Declarations with class body |
true |
Declarations within enum declaration |
true |
Declarations within enum constants |
true |
Declaration within annotation declaration |
true |
Statements within method/constructor body |
true |
Statements within blocks |
true |
Statements within ‘switch’ body |
true |
Statements within ‘case’ body |
true |
‘break’ statements |
true |
Empty lines |
false |
Braces
Brace positions
Setting |
Value |
Class or interface declaration |
Same line |
Anonymous class declaration |
Same line |
Constructor declaration |
Same line |
Method declaration |
Same line |
Enum declaration |
Same line |
Enum constant body |
Same line |
Annotation type declaration |
Same line |
Blocks |
Same line |
Blocks in case statement |
Same line |
‘switch’ statement |
Same line |
Array initializer |
Same line |
Lambda body |
Same line |
Blank Lines
Blank lines in compilation unit
Setting |
Value |
Before package declaration |
0 |
After package declaration |
1 |
Before import declaration |
1 |
Between import groups |
1 |
After import declaration |
1 |
Between class declarations |
1 |
Blank lines within class declarations
Setting |
Value |
Before first declaration |
1 |
Before declarations of the same kind |
1 |
Before member class declarations |
1 |
Before field declarations |
0 |
Before method declarations |
1 |
At beginning of method body |
0 |
Existing blank lines
Setting |
Value |
Number of empty lines to preserve |
1 |
New Lines
Insert new line
Setting |
Value |
in empty class body |
true |
in empty anonymous class body |
true |
in empty method body |
true |
in empty block |
true |
after labels |
true |
in empty enum declaration |
true |
in empty enum constant body |
true |
in empty annotation body |
true |
at end of file |
true |
Array initializers
Setting |
Value |
Insert new line after opening brace of array initializer |
false |
Insert new line before closing brace of array initializer |
false |
Empty statements
Setting |
Value |
Put empty statements on new line |
true |
Annotations
Setting |
Value |
Insert new line after annotations on packages |
true |
Insert new line after annotations on types |
true |
Insert new line after annotations on fields |
true |
Insert new line after annotations on methods |
true |
Insert new line after annotations on local variables |
true |
Insert new line after annotations on parameters |
false |
Insert new line after type annotations |
false |
Control Statements
General
Setting |
Value |
Insert new line before ‘else’ in an ‘if’ statement |
false |
Insert new line before ‘catch’ in a ‘try’ statement |
false |
Insert new line before ‘finally’ in a ‘try’ statement |
false |
Insert new line before ‘while’ in a ‘do’ statement |
false |
‘if else’
Setting |
Value |
Keep ‘then’ statement on same line |
false |
Keep simple ‘if’ on one line |
false |
Keep ‘else’ statement on same line |
false |
Keep ‘else if’ on one line |
true |
Keep ‘return’ or ‘throw’ clause on one line |
false |
Line Wrapping
General settings
Setting |
Value |
Maximum line width |
120 |
Default indentation for wrapped lines |
2 |
Default indentation for array initializers |
2 |
Never join already wrapped lines |
true |
Prefer wrapping outer expressions (keep nested expression on on line) |
true |
Comments
General settings
Setting |
Value |
Enable Javadoc comment formatting |
true |
Enable block comment formatting |
true |
Enable line comment formatting |
true |
Format line comments on first column |
true |
Enable header comment formatting |
false |
Preserve white space between code and line comments |
false |
Never indent line comments on first column |
false |
Never indent block comments on first column |
false |
Never join lines |
false |
Javadoc comment settings
Setting |
Value |
Format HTML tags |
true |
Format Java code snippets inside ‘pre’ tags |
true |
Blank line before Javadoc tags |
true |
Indent Javadoc tags |
true |
Indent description after @param |
true |
New line after @param tags |
true |
/** and */ on separate lines |
true |
Remove blank lines |
true |
Block comment settings
Setting |
Value |
/* and */ on separate lines |
true |
Remove blank lines |
true |
Line width
Setting |
Value |
Maximum line width for comments |
120 |
Off/On Tags
Setting |
Value |
Enable Off/On tags |
true |
Off tag |
@formatter:off |
On tag |
@formatter:on |
Editor
Save Actions
Setting |
Value |
Perform the selected actions on save |
true |
Format source code |
Format all lines |
Organize imports |
true |
Additional actions |
true |
Code Organizing
Formatter
Setting |
Value |
Remove trailing whitespace |
All lines |
Correct indentation |
true |
Members
Setting |
Value |
Sort members |
false |
Code Style
Control statements
Setting |
Value |
Use blocks in if/while/for/do statements |
Always |
Convert ‘for’ loops to enhanced |
true |
Expressions
Setting |
Value |
Use parentheses in expressions |
Only if necessary |
Variable declarations
Setting |
Value |
Use modifier ‘final’ where possible |
true |
Private fields |
true |
Parameter |
true |
Local variables |
true |
Functional interface instances
Setting |
Value |
Convert functional interface instances |
Use lambda where possible |
Member Accesses
Non static accesses
Setting |
Value |
Use ‘this’ qualifier for field accesses |
Only if necessary |
Use ‘this’ qualifier for method accesses |
Only if necessary |
Static accesses
Setting |
Value |
Use declaring class as qualifier |
true |
Qualify field accesses |
false |
Qualify method accesses |
false |
Change all accesses through subtypes |
true |
Change all accesses through instances |
true |
Missing Code
Annotations
Setting |
Value |
Add missing Annotations |
true |
‘@Override’ |
true |
Implementations of interface methods (1.6 or higher) |
true |
‘@Deprecated’ |
true |
Unnecessary Code
Unused code
Setting |
Value |
Remove unused imports |
true |
Remove unused private members |
true |
Types |
true |
Constructors |
true |
Fields |
true |
Methods |
true |
Remove unused local variables |
true |
Unnecessary code
Setting |
Value |
Remove unnecessary casts |
true |
Remove unnecessary ‘$NON-NLS$’ tags |
true |
Usage
Eclipse settings
In order to automatically configure a single project within, use the following Maven configuration:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>${version.resources-plugin}</version>
<executions>
<execution>
<id>jdt-settings</id>
<goals>
<goal>process</goal>
</goals>
<configuration>
<attachToMain>false</attachToMain>
<attachToTest>false</attachToTest>
<resourceBundles>
<resourceBundle>com.github.sebhoss:jdt-settings:${version.jdt-settings}</resourceBundle>
</resourceBundles>
<outputDirectory>${project.basedir}/.settings</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
Maven/CI settings
In order to re-use the same compiler settings in both the Eclipse project configuration and the normal build system, add the following configuration on top the previous one:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler-plugin}</version>
<configuration>
<compilerId>jdt</compilerId>
<compilerArguments>
<properties>${project.basedir}/.settings/org.eclipse.jdt.core.prefs</properties>
</compilerArguments>
</configuration>
<dependencies>
<!-- This dependency provides the implementation of compiler "jdt" -->
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>${version.tycho}</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</build>
Replace the placeholders with an appropriate version: