after running my JUnit tests I use the Maven Surefire Report plugin (http://maven.apache.org/plugins/maven-surefire-report-plugin/) to generate a HTML test report. This results in the following file:
./target/site/surefire-report.html
I know that there is a Maven PDF plugin to generate PDF files (http://maven.apache.org/plugins/maven-pdf-plugin/surefire-report.html). But I don't manage to get it working. I included it in my 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>
When I try to run it I get an error that some source directory doesn't exist:
...
[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]
...
The error is not so surprising as I don't have a ./src/site folder. But how can I configure the PDF plugin so it takes my HTML report from ./target/site/surefire-report.html as source file for the PDF?
From the documentation of maven pdf plugin, the plugin needs a file that contains the DocumentModel of the PDF to generate.
It is by default src/site/pdf.xml
, which is why the plugin fails when it does not find this file.
The plugin is intended to generate the pdf version of the report generated by the maven site plugin. As such, it generates the pdf versions of all reports for the project, which would include the surefire-report, if configured.