-- Expanding Properties within Checkstyle configuration files --
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.
First there are some properties that are automatically expanded by the plug-in:
-
${basedir} - gets mapped to the current project
directory
-
${project_loc} - same as ${basedir}
-
${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 you can write the properties you
need to be expanded into a .properties file that lies in
the same directory as the configuration file and has the same name. For instance:
D:/path/to/my/config/myCheckConfiguration.xml
can resolve properties defined in
D:/path/to/my/config/myCheckConfiguration.properties
Expandable properties within your configuration file will then be resolved from the
corresponding .properties 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
|