1
votes

After default config, maven is only outputting the Checkstyle report for source classes, not Junit test classes. Note I'm not looking for the surefire test report output.

from pom.xml:

<reporting>
 <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-checkstyle-plugin</artifactId>
      <version>2.17</version>
      <reportSets>
        <reportSet>
          <reports>
            <report>checkstyle</report>
          </reports>
        </reportSet>
      </reportSets>
      <configuration>
        <configLocation>src/main/resources/apcheckstyle.xml</configLocation>
        <module name="LineLength">
          <property name="max" value="120"/>
        </module>
      </configuration>
    </plugin>
</plugins>

I changed dependency scope for junit from test to compile:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>compile</scope>
</dependency>

Maven is configured to generate the checkstyle reports using the mvn site plugin. I tried adding a user property includeTestResources as true, but this did not help. The documentation states that the default value is true, so I took it out.

Here is the maven output during checkstyle generation.

from javadocs:

Generating C:\Users\Administrator\Projects\lht657aws\target\site\testapidocs\help-doc.html...

checkstyle plugin runs:

[INFO] Generating "Checkstyle" report --- maven-checkstyle-plugin:2.17

[INFO] There are 210 errors reported by Checkstyle 6.11.2 with src/main/resources/apcheckstyle.xml ruleset.

is following the problem-? all the java under src is getting processed, just java under test is being skipped:

[WARNING] Unable to locate Source XRef to link to - DISABLED

after checkstyle, maven project info report starts

[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:2.9

2
Edited to clarify that this is actually about the checkstyle report and added the output from Maven. - John Meyer

2 Answers

4
votes

Add the Maven Surefire Report plugin to your pom XML

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
      <outputDirectory>path/to/the/report</outputDirectory>
    </configuration>
</plugin>

And add the goal surefire-report:report to your maven call

See the documentation here: Maven Surefire Report Plugin

EDIT

I've misunderstood the question, try to add this section with desired configurations to your pom.

<reporting>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>2.17</version>
      <reportSets>
        <reportSet>
          <id>main_checks</id>
          <reports>
            <report>checkstyle</report>
          </reports>
          <configuration>
            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
            <includeTestSourceDirectory>false</includeTestSourceDirectory>
            <configLocation>config/maven_checks.xml</configLocation>
            <outputDirectory>${project.reporting.outputDirectory}/main-checks/</outputDirectory>
          </configuration>
        </reportSet>
        <reportSet>
          <id>test_checks</id>
          <reports>
            <report>checkstyle</report>
          </reports>
          <configuration>
            <sourceDirectory></sourceDirectory>
            <testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
            <configLocation>config/sun_checks.xml</configLocation>
            <outputDirectory>${project.reporting.outputDirectory}/test-checks/</outputDirectory>
          </configuration>
        </reportSet>
      </reportSets>
    </plugin>
  </plugins>
</reporting>
0
votes

Maven sure fire plugin is used for generating the Test reports. See the additional documentation here:

http://maven.apache.org/surefire/maven-surefire-report-plugin/

You need to include this plugin in your POM.xml and provide path to create reports (generally a directory in project). While making the build make sure you are including goal for this.