eclipsereportingmaven-surefire-plugin

Change output directory of maven surefire-plugin


I'm trying to change the output folder for the XML files which get generated by the surefire-plugin in a maven project. I stated the target output folder inside the configuration brackets of the report-plugin as well as in the maven-site-plugin (mentioned in the documentation). I also tried to state the maven-site-plugin within the reporting block but that doesn't seem to work as well. My XML files always get written into the default surefire-reports folder.

My pom.xml has following entries:

<reporting>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-report-plugin</artifactId>
         <version>2.22.0</version>
         <configuration>
            <showSuccess>true</showSuccess>
            <outputDirectory>${basedir}/pb-reporting/test-output</outputDirectory>
            <!--<skipSurefireReport>true</skipSurefireReport>-->
         </configuration>
      </plugin>
   </plugins>
</reporting>

<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.5.1</version>
         <configuration>
            <source>1.7</source>
            <target>1.7</target>
            <!--<executable>/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.95-2.6.4.0.el7_2.x86_64/bin/javac</executable>-->
            <compilerArguments>
               <endorseddirs>${endorsed.dir}</endorseddirs>
            </compilerArguments>
         </configuration>
      </plugin>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-site-plugin</artifactId>
         <version>3.7.1</version>
         <configuration>
            <outputDirectory>${basedir}/pb-reporting/test-output</outputDirectory>
         </configuration>
      </plugin>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <version>2.22.0</version>
         <configuration>
            <testFailureIgnore>true</testFailureIgnore>
         </configuration>
      </plugin>
   </plugins>
</build>

Project hierarchy looks like this: Image of project hierarchy


Solution

  • Configuring the output directory in the surefire-reports-plugin and maven-site-plugin isn't enough. The solution is to state the reportsDirectory also in maven-surefire-plugin within the build block:

    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
       <version>2.22.0</version>
       <configuration>
          <reportsDirectory>${basedir}/pb-reporting/test-output</reportsDirectory>
          <testFailureIgnore>true</testFailureIgnore>
       </configuration>
    </plugin>