如何从不相关的项目中生成组合的Maven站点?

时间:2011-06-29 14:11:12

标签: maven

我想以Maven site 目标生成的网站形式创建几个Maven项目的概述。这些项目是不同产品的一部分,有些具有亲子关系,有些则依赖于其他产品。

该网站应结合所有项目的信息,包括JavaDoc,Checkstyle / PMD检查,测试结果和代码覆盖率指标。

我创建了一个POM文件,将每个现有项目聚合为一个模块,每个项目都在子文件夹中可用,但输出不会合并到一个站点中。

1 个答案:

答案 0 :(得分:2)

您可以通过将所有项目的project.build.directory设置为公共文件夹来完成此操作。这可以通过将路径作为参数传递给构建来实现。然后,您可以在公共目标文件夹上运行站点目标。如果您在持续集成环境中运行maven,则可以通过在maven任务中设置targetpath来完成此操作。否则,您必须在命令行上指定它。

<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

为了使开发人员的构建保持不变,您可以创建一个在命令行未提供targetpath时激活的配置文件。

<profiles>
  <profile>
    <id>dev</id>
    <activation>
      <property>
        <name>!targetpath</name>
      </property>
    </activation>
    <properties>
      <targetpath>target</targetpath>
    </properties>
  </profile>
</profiles>
相关问题