Maven Checkstyle Plugin - Change location of file checkstyle-checker.xml in ${project.build.directory}
Asked Answered
O

1

6

Trying to clean up my ${project.build.directory}, I noticed that maven-checkstyle-plugin puts three files into my target folder: checkstyle-checker.xml, checkstyle-cachefile and checkstyle-result.xml.

I was able to redirect the last two into their own folder target/checkstyle:

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
      <cacheFile default-value="${project.build.directory}/checkstyle/checkstyle-cachefile"/>
      <configLocation>google_checks.xml</configLocation>
     [...]
      <outputFile default-value="${project.build.directory}/checkstyle/checkstyle-result.xml">${checkstyle.output.file}</outputFile>
    </configuration>
    [...]
    <executions>
      <execution>
        <phase>verify</phase>
        <goals>
          <goal>check</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

All I could find about checkstyle-checker is under propertiesLocation. There is says:

If successfully resolved, the contents of the properties location is copied into the ${project.build.directory}/checkstyle-checker.properties file before being passed to Checkstyle for loading.

Can I change the location the contents of the properties location are copied into? Or is there another way to make the plugin write the checkstyle-checker.xml file into my custom folder target/checkstyle?

Ortolan answered 20/2, 2018 at 9:35 Comment(1)
nice task, but "best practice" to "clean up my 'target folder'" is (still): mvn clean (and sleep tight;)Anything
A
3

You cannot change the location of ${project.build.directory}/checkstyle-checker.properties without modifying/overwriting the plugin.

The documentation sounds clear regarding this point.

A gaze into the source code reveals, that checkstyle-checker.properties is hard coded. ... and the path (${project.build.directory}) is "deep in" maven/plexus.

Same applies to (the location of) checkstyle-checker.xml: DefaultCheckstyleExecutor.java#L723

Anything answered 10/11, 2021 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.