-- Configuring File Sets --

In the getting started section we configured our project using the simple configuration approach.
With the simple configuration all files in your project get checked by the same check configuration.

Checkstyle Properties Page
Using the simple project configuration might suite you in most cases there are cases where you might need more control:

  1. You only want to check certain files based on the file name or exclude files based on the file name

  2. You want to check parts of your project with one check configuration and another part of your project with another check configuration

To give you fine grained control over which files get checked with which check configuration the plug-in allows you to configure file sets.
A File Set is a collection of files within one project that need to be checked with the same Check Configuration. A File Set is defined using regular expressions to select the files to include and exclude from the File Set.

Deselect the check box Use simple configuration on the upper right of the Checkstyle Properties Page.

Checkstyle Properties Page advanced
Now a table is displayed containing all file sets configured for this project.
There is already a default file set named all in the table.


To create a new file set click the Add... button, to edit an existing file set select the file set in question and use the Edit... button:
Both actions will result in the Checkstyle File Set Editor opening.

Checkstyle File Set Editor
Each File Set is given a unique name and a Check Configuration. Select from the drop down list the Check Configuration you want used when this File Set is audited.
If no Check Configurations appear in the drop down list then you will need to first create one. See Creating a Check Configuration for information on how to create a Check Configuration.

Next, enter a series of regular expressions to select which files you want to include in the File Set. Each regular expression can be used to include or exclude files (the default regular expressions matches all files ending with ".java").
The regular expression is matched against the fully qualified file name within the project.
That is, the entire path to the file starting with the name of the top level folder within the project and progressing through each folder down to the file, with '/' being used as the path separator.
For example, consider the project in the figure below. The CheckstylePlugin.java file has a complete path of src/com/atlassw/tools/eclipse/checkstyle/CheckstylePlugin.java

Package Explorer

The include/exclude setting of the last regular expression a file matches will determine if the file is included in or excluded from the File Set.
This lets you create a regular expression that matches a number of files and then refine the selection with a series of exclusion expressions.
To adjust the order of the regular expressions use the Up and Down buttons to move the selected expression up or down in the list.
The bottom section of the Checkstyle File Set Editor shows which files from your project are included in your file set based on the current settings.
This section will update as you change the regular expression patterns and their include/exclude state.

Each project in your Eclipse workspace can have any number of File Sets defined, each with a different set of files and each with a different Check Configuration.
You can also turn off the checking of a File Set using the Enabled check box in the properties window.