Importing

Use the Import... button to import an already-saved code convention. Since version 1.6, Jalopy also supports importing of Checkstyle configurations (version 3.5 or later).

Jalopy is able to import code conventions from both local and distributed locations. Just specify a valid Internet address (either starting with "http://", "https://" or "www.") for the latter.

Since Jalopy 1.7, exported code conventions store the names of their profile. During import it is therefore possible to recreate the profile structure. When importing a single profile and the original profile does not already exist, you will be asked whether it should be created and the exported settings imported into this profile. Otherwise, the settings will be imported into the currently active profile. Checkstyle configurations will always be imported into the currently active profile. Importing a file that contains several code conventions, will always recreate the original profiles if they should not already exist.

Versions prior to 1.0b8 stored the backup directory always as an absolute file. Therefore after importing a very old code convention, you should check whether this directory points to your preferred backup directory. This advice holds true even for later versions in case you've changed any of the default directories (backup, history, message log).

Importing Checkstyle configurations

Importing Checkstyle configurations only means a best effort. There is no guarantee that the resulting Jalopy code convention exactly matches your style preferences because some Checkstyle modules might be ambiguous or missing at all.

E.g. take the following "ParenPad" module configuration:

<module name="ParenPad">
    <property name="tokens" value="METHOD_CALL"/>
    <property name="option" value="nospace"/>
</module>

It only defines a white space check for method call parentheses, but does not express the preference for other parentheses. It could be "space" or "nospace". In such a case, Jalopy will assume the default value Checkstyle uses when no token is defined ("nospace" in the example).

Another common case is the <whitespaceAfter> module. Without any tokens defined, it will check for white space after three tokens (comma, semi, type cast parenthesis). But what if you limit the check to only two tokens (comma, semi)? Does it mean that no white space should appear after the right parenthesis of type casts? Or should it be allowed? Checkstyle accepts both, but Jalopy will assume that you don't want white space after the token in such a case.

The same problem appears when a Checkstyle module is not contained in your configuration. Jalopy can't interfere any preferences in a such case and assumes the default settings of an empty module config.

In general importing works better the more Checkstyle modules are defined.

It is recommended that you test the resulting Jalopy code convention against the Checkstyle configuration after importing. Just format some source files into a temporary directory and run Checkstyle to check for any style violations. This way you can be sure that the import covered all your preferences.

To import a Checkstyle configuration you need to press the Import... button and enter or select the configuration file that should be imported. The file dialog provides a file filter for Checkstyle configurations, but because all configuration files use the .xml extension, it actually doesn't matter what file filter is selected.

Figure 2.18. Choose Checkstyle Configuration

Choose Checkstyle Configuration

After the import has finished, a confirmation dialog appears that lets you display a report of the imported modules.

Figure 2.19. Import Checkstyle Configuration Confirmation

Import Checkstyle Configuration Confirmation