如何从不相关的项目中生成合并的Maven站点? [英] How to generate a combined Maven site from unrelated projects?

查看:74
本文介绍了如何从不相关的项目中生成合并的Maven站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

The site should combine the information from all projects and include JavaDoc, Checkstyle/PMD checks, test results and code coverage metrics.

我已经创建了一个POM文件,该文件将每个现有项目作为一个模块进行聚合,每个项目都在子文件夹中,但是输出不会合并到一个站点中.

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.

推荐答案

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

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

要使开发人员的构建保持不变,您可以创建一个配置文件,当命令行未提供targetpath时将激活该配置文件.

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>

这篇关于如何从不相关的项目中生成合并的Maven站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆