Uploaded image for project: 'Maven Checkstyle Plugin'
  1. Maven Checkstyle Plugin
  2. MCHECKSTYLE-299

build type check goal ignored source options when using phases "test site"

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.15
    • None
    • checkstyle:check
    • None

    Description

      I have a project where we enforce a zero-warnings policy. For this purpose we have included a call to checkstyle:check in the build phase using the following configuration:

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.15</version>
          <configuration>
              <configLocation>${project.basedir}/codecheck/checkstyle.xml</configLocation>
              <propertyExpansion>config_loc=${project.basedir}/codecheck</propertyExpansion>
              <includeTestSourceDirectory>true</includeTestSourceDirectory>
              <consoleOutput>true</consoleOutput>
              <violationSeverity>warning</violationSeverity>
              <failOnViolation>true</failOnViolation>
              <sourceDirectory>${project.basedir}/src</sourceDirectory>
          </configuration>
          <executions>
              <execution>
                  <id>checkstyle-validate</id>
                  <phase>validate</phase>
                  <goals>
                      <goal>check</goal>
                  </goals>
              </execution>
          </executions>
      </plugin>
      

      Additionally, checkstyle is set up as a reporting goal in the reporting section:

      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>2.15</version>
          <configuration>
              <configLocation>${project.basedir}/codecheck/checkstyle.xml</configLocation>
              <propertyExpansion>config_loc=${project.basedir}/codecheck</propertyExpansion>
              <includeTestSourceDirectory>true</includeTestSourceDirectory>
              <sourceDirectory>${project.basedir}/src</sourceDirectory>
          </configuration>
      </plugin>
      

      The project contains multiple source trees and some contain generated code. Therefore it is necessary to restrict checkstyle to only one of these trees where the manually maintained code lives. Otherwise, the build would fail due to warnings being detected in generated code.

      This shown configuration works well when calling maven all of the following ways:

      mvn compile
      mvn test
      mvn site
      mvn test site
      

      However, when changing the deprecated sourceDirectory elements to the list syntax with sourceDirectories, the last call mvn test site starts to fail and ignores the specified source directories. All previous other calls still work as expected.

      When looking at the effective configuration using mvn -X I could see, that in the last call version with "test site", the sourceDirectories list of the check goal is again the complete list of source trees instead of the specified one.

      Since we are also using some plugins to include the generated code etc., a reference to the complete POM might be helpful for debugging:
      https://code.cor-lab.org/projects/rsb/repository/rsb-java/revisions/master/entry/pom.xml

      Attachments

        Activity

          People

            Unassigned Unassigned
            languitar Johannes Wienke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: