1

I would like to create a general overview of several Maven projects in the form of a website generated with 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.

Kwebble
  • 2,065
  • 14
  • 23

1 Answers1

2

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>
Ryan Gross
  • 6,423
  • 2
  • 32
  • 44
  • This generates a site that contains the combined Javadoc, but not Checkstyle reports. I does create a /target/site folder for each separate project. Tomorrow I'll check the separate project POM's configuration. – Kwebble Jun 29 '11 at 16:13
  • I can't get it to work. The documentation of the site plugin doesn't mention a setting. – Kwebble Jun 30 '11 at 08:29
  • The inputDirectory is for the `site:deploy` or `site:stage` goal. `site:site` should build the sites under ${targetpath}/${artifactId}, then `site:stage` should copy them to a common location. – Ryan Gross Jun 30 '11 at 14:38
  • Thanks for your help Ryan, but I don't think I can get it to work without spending a large amount of time on it. That's probably my lack of understanding of Maven, but I find it a very unintuitive tool to work with. I'll accept your answer because I assume its useful to someone with a better understanding of Maven. – Kwebble Jun 30 '11 at 21:38