This chapter looks at the different places where the Checkclipse plugin can be configured. In fact we have three different levels used for the configuration.
The project properties. This settings are specific for the actual Eclipse project.
The workspace preferences are used when no project specific values are defined.
The plug-in defaults are used when no project and workspace settings are set. The default values can be changed by creating a fragment plug-in.
The project properties define the project-specific Checkstyle settings. All files used for the project-specific configuration must reside inside the Eclipse workspace.
The figure above shows the Tab Configuration of the project properties. Here you can do the following settings:
With this checkbox you can enable or disable Checkstyle for the current project.
This checkbox controles, if the project classpath should be used by Checkstyle. It is highly recommended that this checkbox is enabled (it is by default). Some Checkstyle checks won't work if this is disabled. Plugin default: Checked
This is the file, that defines the Checkstyle checks to use on the current project. If no file is selected, the file from the workspace configuration is used.
This file contains properties needed to use the Checkstyle Configuration File defined above. This is only needed if the Checkstyle configuration file contains variables. If no file is selected, the file from the workspace configuration is used.
This list can be used to add jar files containing custom checkstyle checks to the classpath of the Checkstyle checker. The checkstyle checker is loading its check classes via this classpath.
The figure above shoes the Tab File Filter of the project properties. Here you can configure which files should be included or excluded from the Checkstyle checks.
The upper half of the page contains the editor for the file filters, while the lower half shows the file included or excluded by this filters.
The checkbox Only check in project source
directories
restricts the filters to files that are in the
source directory (or directories) of the project. All files outside
this directory (or directories) are excluded, regardless if they
match any given pattern. Plugin default: Checked
The file filter editor is a table with two columns. The second column contains a regular expression (see JavaDoc of java.util.regex.Pattern). The first column either contain the word "include" or "exclude" and define what should happen, if a filename matches the regular expression.
Plugin default: include "\.java$", include "\.properties$"
Note:The filename that is checked against the regular expression is a project relative path and the path elements are separated by a '/' (forward slash).
The lower part of the properties page shows the list of the files included or excluded from the checkstyle checking, depending on the button selected on the right hand side of the list. If a entire directory tree is excluded, only the name of the toplevel directory followed by a "/*" is shown.
This section describe the configuration, that is done on the workspace level. Some of the configuration entries can be overwritten by entries on the project level.
The figure above shows the worksapce configuration (aka preferences) for Checkclipse.
If this is enabled, the project directory is set as the base directory for Checkstyle. This means, that all filenames are relative to the project and are not absolute. This setting is recommended.
Plugin default: Checked.
If this is enabled, Checkclipse will always run a clean build on the current project if a project property is changed or run a clean build on all projects if the workspace configuration is changed.
Plugin default: Checked.
If this enabled, the name of the Checkstle check emitting a diagnostic message is appended to the message text. This is usefull if you want to use Checkstyles SuppressionFilter or SuppressionCommentFilter, as you need the name of the check for this.
Plugin default: Checked.
This is the file, that defines the Checkstyle checks to use if nothing is configured in a project.
This file contains properties needed to use the Checkstyle Configuration File defined above. This is only needed if the Checkstyle configuration file contains variables.
This section describes the default configuration values of the plugin.
Note: The default Checkstyle configuration delivered with the plug-in is rather lax. This has historical reasons. There is a way to define your own default values by creating a own plug-in that extends the Checkclipse plug-in. This is suprisingly easy and doesn't involve programming. We will explain this later.