Change output directory of maven surefire-plugin

筅森魡賤 提交于 2019-12-13 05:48:29

问题


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:

Any help would be appreciated and thank you in advance for your efforts


回答1:


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>



回答2:


According to the documentation you have to use the reportsDirectory instead of outputDirectory which does not exist.



来源:https://stackoverflow.com/questions/51594391/change-output-directory-of-maven-surefire-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!