4

I tried adding this code to my pom.xml

<reporting>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-report-plugin</artifactId>
    <version>2.12.4</version>
    <configuration>
      <outputDirectory>D:/eclipse_ws/reports</outputDirectory>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-site-plugin</artifactId>
    <version>2.1</version>
    <configuration>
      <outputDirectory>D:/eclipse_ws/reports</outputDirectory>
    </configuration>
  </plugin>
</plugins>

and executing this in windows command prompt

mvn surefire-report:report -DoutputDirectory=D:/eclipse_ws/reports

I am still getting the surefire-report.html report in the target/site/ folder itself. Is it possible to change the directory in the way I did? Did I make any mistake?

4

2 回答 2

1

从报告插件文档配置肯定报告的输出位置似乎确实是错误的。

我在这个文档页面<xrefLocation>上找到了目标参数的 描述surefire-report:report,它指的是${project.reporting.outputDirectory}值。我在我的 pom.xml 中尝试过,它有效:

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>3.0.0-M1</version>
        </plugin>
    </plugins>
    <outputDirectory>${basedir}/new-reports-dir</outputDirectory>
</reporting>
于 2018-11-19T09:03:51.760 回答
0

官方文档建议类似于 OP 的配置应该可以工作,但事实并非如此。

对我有用的是:

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <reportsDirectory>C:/eclipse_ws/reports</reportsDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

相对路径也可以。此外,您不需要将目录指定为命令行参数,因为您已经在配置中这样做了。

于 2015-05-08T20:59:50.660 回答