Usage

In order to integrate Jalopy into your build process, you need to edit your pom.xml under the plugins section:

<project>
  [...]
  <plugins>
    <plugin>
      <groupId>triemax</groupId>
      <artifactId>jalopy-maven</artifactId>
      <configuration>
        [...]
      </configuration>
      <executions>
        <execution>
          <phase>process-classes</phase>
          <goals>
            <goal>format</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</project>

This would execute Jalopy during the process-classes phase. Please note that you should always apply formatting after the compile phase has finished in order to ensure that the project is clean, but you're otherwise free to choose the phase that best suits your needs. For more information about the Maven build lifecycle, please refer to the "Maven Build Lifecycle Guide". It contains a reference of the available build phases.

Configuration

Naturally the Plug-in provides a few parameters to configure its behavior.

Table 12.1. Jalopy Maven Plug-in parameters

PropertyTypeDescriptionSinceRequired
backupBoolean Sets whether backup copies of all processed Java source files should be kept. If omitted, the corresponding code convention setting will be used (see the section called "Backup"). 1.7No
classpathElementsList Defines the classpath to use for type lookup. By default, the project classpath (${project.compileClasspathElements}) is used and it should seldom be necessary to override it. 1.7No
conventionString Sets the location to the code convention file to use - given either relative to the project's base directory or as an absolute local path or Internet address (refer to the section called "Importing" for information how to export your settings). If omitted, the current settings are used, if available. Otherwise the Jalopy build-in defaults will be used. 1.7No
destDirString Sets the destination directory to create/copy all formatting output into. If the given directory does not exist, it will be created. If omitted, all input files will simply be overridden. 1.7No
encodingString Sets the encoding that controls how Jalopy interprets text files containing characters beyond the ASCII character set. Defaults to the platform default encoding. 1.7No
environmentMap Defines temporary environment variables overrides. 1.7No
excludesList A list of exclusion filters. Uses the standard Maven pattern syntax. Please note that Jalopy ignores all files it cannot format by default, so exclusions are only necessary if you want to omit formatting for certain files, like e.g. test data files etc. 1.7No
failOnErrorBoolean Sets whether a run should be held if errors occurred. Defaults to "true". 1.7No
fileFormatStringSets the file format of the output files. The file format controls what end of line character is used. Either one of "UNIX", "DOS", "DEFAULT" or "AUTO" can be used (case insensitive). Defaults to "AUTO". 1.7No
forceBooleanSets whether the formatting of files should be forced, even if a file is up-to-date. Defaults to "false". 1.7No
forkBooleanSets whether the processing should be performed in a separate VM. Defaults to "false". 1.7No
historyString Sets the history policy to use. Either one of "ADLER32", "CRC32" or "NONE" can be used (case insensitive). If omitted, the corresponding code convention setting will used (see the section called "History"). 1.7No
includesList A list of inclusion filters for the compiler. Uses the standard Maven pattern syntax. Please note that Jalopy ignores all files it cannot format by default, so inclusions are only necessary if you want to omit formatting for certain files, like e.g. test data files etc. 1.7No
inputEncodingString Sets the encoding that controls how Jalopy interprets text files containing characters beyond the ASCII character set. Defaults to the platform default encoding. Please note that this setting always overrides encoding. 1.7No
javadocStringIndicates whether Javadoc related messages should be printed. Defaults to "true". 1.7No
logLevelString Specifies the logging level for message output. Either one of "ERROR", "WARN", "INFO" or "DEBUG" can be used (case insensitive). If omitted, the current code convention settings will be used (see the section called "Categories"). 1.7No
logFileString Specifies the log file to use for logging output. The format of the logging output is determined by the extension of the given file. Valid extensions are ".log" for a custom plain text format, ".xml" for a plain XML format and ".html" for an hierarchical HTML report. If omitted, the current code convention setting will be used (see the section called "Logging"). 1.7No
outputEncodingString Sets the character encoding Jalopy uses to write files. Defaults to the platform default encoding. Please note that this setting always overrides encoding. 1.7No
profileString Sets the Jalopy profile that should be activated during the formatting run (refer to the section called "Main window" for more information about profiles). The currently active profile will be restored after formatting. Please note that the profile must exist! 1.7No
repositoryBoolean Indicates whether the disk-based type repository should be used for type lookup. When disabled, this currently means that all dependent features despite the import optimization will be disabled! You may want to use this option if you commonly format a single file or only a small sets of files in order to avoid the maintenance overhead of the type repository. Defaults to "true". 1.7No
sourcesList The source directories containing the sources to be formatted. When omitted, uses the directories defined for the compiler (${project.compileSourceRoots}) instead. 1.7No
testBooleanSets whether formatting output should actually be written to disk. If set to "true" no output will be written to disk. The default is "false". 1.7No
threadsIntegerSpecifies the number of processing threads to use. Integer between 1 - 8. Defaults to "1". 1.7No

To configure the Plug-in, you specify elements named after the available parameters where the contents of an element is the value to be assigned to the parameter.

<plugin>
  <groupId>triemax</groupId>
  <artifactId>jalopy-maven</artifactId>
  <configuration>
    <threads>4</threads>
    <profile>test</profile>
  </configuration>
  [...]
</plugin>

For parameters of type List you would use multiple element tags to map the different values to the list.

<plugin>
  <groupId>triemax</groupId>
  <artifactId>jalopy-maven</artifactId>
  <configuration>
    <includes>
      <include>com/foo/siri/**</include>
      <include>com/foo/lana/**</include>
    </includes>
    <excludes>
      <exclude>**/*.sqlj</exclude>
      <exclude>**/*Test/**</exclude>
    </excludes>
  </configuration>
  [...]
</plugin>

Configuring Maps works similar: elements are named after the keys and the element contents is the value to be assigned to the key.

<plugin>
  <groupId>triemax</groupId>
  <artifactId>jalopy-maven</artifactId>
  <configuration>
    <environment>
      <lead>John Doo</lead>
      <office>Alta Nova</office>
    </environment>
  </configuration>
  [...]
</plugin>

For a complete example, please refer to the section called "Example" below.