Checkstyle contains a feature
that lets you define module properties in a way that they can
expanded dynamically when the configuration is loaded.
Such a property is defined using the well known
${property_name}
notation.
Normally these properties are resolved from command line or ant properties.
Of course this does not work
within the plug-in so using a checkstyle configuration containing such expandable properties will probably
fail.
But as you might have thought there are some features in place to help you out in this case.
When a Check Configuration is set up the plugin will check the Checkstyle configuration file for unresolved
properties.
When found the plugin will warn you that this configuration cannot be used until those
properties can be resolved.
To resolve such properties you have a variety of options.
First there are some properties that are automatically expanded by the plug-in:
${basedir}
& ${project_loc}
- gets mapped to the current project
directory
${workspace_loc}
- gets mapped to the current Eclipse workspace directory
${config_loc}
& ${samedir}
- get mapped to the directory the configuration
file lies in
If you have more properties that need to be expanded there is another feature for you.
Using External, Remote or Project Relative Configuration can be expanded from a .properties
file in
the same directory as the Checkstyle configuration file having the same name (except the file extension).
For instance:
C:/path/to/my/config/myCheckConfiguration.xml
can resolve properties defined in
C:/path/to/my/config/myCheckConfiguration.properties
Additionally properties can be resolved from Classpath Variables (set up in workspace preferences) and from Environment Properties, passed into the Eclipse JVM using the -D parameter.
If all this stuff doesn't suit your needs the plugin supports storing properties with the Check Configuration
setup.
You might have already noted the Additional properties... button located in the lower left
of a Check Configuration setup dialog.
Pressing this button will lead you to another dialog where you can
input properties and their values
To aid in this task the plugin offers to find unresolved properties for
you.
Properties set up here will be stored with the Check Configuration data, for Global Configurations
within the plugins workspace state location, for Local Configurations within the .checkstyle file.
Note that the plug-in supports 'property chaining' to let you use 'properties within properties'.
With this feature you can write something like this in your .properties
file:
property1=abc
property2=${property1}def
Using ${property2}
in your checkstyle configuration will then be resolved to:
abcdef