运行我的 JUnit 测试后,我使用 Maven Surefire Report 插件 (http://maven.apache.org/plugins/maven-surefire-report-plugin/) 生成 HTML 测试报告。这将产生以下文件:
./target/site/surefire-report.html
我知道有一个 Maven PDF 插件可以生成 PDF 文件(http://maven.apache.org/plugins/maven-pdf-plugin/surefire-report.html)。但我无法让它工作。我将它包含在我的 pom.xml 中:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<executions>
<execution>
<id>pdf</id>
<phase>test</phase>
<goals>
<goal>pdf</goal>
</goals>
<configuration>
<outputDirectory>/tmp</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
当我尝试运行它时,我收到一些源目录不存在的错误:
...
[mvn] [INFO] [pdf:pdf {execution: default-cli}]
[mvn] [INFO] ------------------------------------------------------------------------
[mvn] [INFO] Building VB Common
[mvn] [INFO] task-segment: [pdf:pdf]
[mvn] [INFO] ------------------------------------------------------------------------
[mvn] [INFO] [pdf:pdf {execution: default-cli}]
[mvn] [INFO] ------------------------------------------------------------------------
[mvn] [ERROR] BUILD ERROR
[mvn] [INFO] ------------------------------------------------------------------------
[mvn] [INFO] Error during document generation: Source directory doesn't exists (/home/user/myproject/src/site).
[mvn]
...
这个错误并不奇怪,因为我没有 ./src/site 文件夹。但是如何配置 PDF 插件,以便将来自 ./target/site/surefire-report.html 的 HTML 报告作为 PDF 的源文件?