How to generate a combined Maven site from unrelated projects?
I would like to create a general overview of several Maven projects in the form of a website generated w开发者_C百科ith the Maven site goal. The projects are part of different products, some have a parent-child relation, some have dependencies on others.
The site should combine the information from all projects and include JavaDoc, Checkstyle/PMD checks, test results and code coverage metrics.
I've created a POM file that aggregates each existing project as a module, with each project available in subfolder, but then the output is not combined into a single site.
You can do this by setting project.build.directory on all of your projects to a common folder. This can be accomplished by passing in the path as a parameter to the build. You can then run the site goal on the common target folder. If you run maven from in a continuous integration environment, you can do this by setting targetpath in your maven task. Otherwise you would have to specify it on the command line.
<project>
<build>
<directory>${targetpath}/${project.artifactId}</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.3</version>
<configuration>
<inputDirectory>${targetpath}</inputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
mvn clean deploy -Dtargetpath=Path/To/Build/Output
To keep the build the same for your developers, you could create a profile that is activated when targetpath
is not provided by the command line.
<profiles>
<profile>
<id>dev</id>
<activation>
<property>
<name>!targetpath</name>
</property>
</activation>
<properties>
<targetpath>target</targetpath>
</properties>
</profile>
</profiles>
精彩评论