2011-05-12 86 views
7

我有很多的子模块Maven项目,我用父POM来控制插件目录像下面Maven站点多模块

-pom.xml (parent pom) 
+- submodule1 
+- submodule2 
+- src\site\site.xml 
因此

src\site\site.xml包含像下面

自定义菜单
<project> 
    .... 
    <body> 
    <menu name="Overview"> 
    <item name="Introduction" href="introduction.html"/> 
    </menu> 
    <menu name="Development"> 
     <item name="Getting started" href="designenv.html"/> 
     <item name="FAQ" href="designfaq.html" /> 
     <item name="Javadoc" href="apidocs/index.html" /> 
    </menu> 
    <menu ref="modules"/> 
    <menu ref="reports"/> 
</body> 
</project> 

我跑在根(从maven site plugin建议)mvn site:stage之后,父网页是好的,而<sub-modules>\index.html不包含任何菜单(没有项目信息&项目报告)

此外,我注意到,如果我跑下的子模块mvn site,中的index.html不包含留下的任何菜单,而单个HTML像pmd.html目录中,的license.html

  • 我需要在每个子模块中添加src\site\site.xml还是其他更好的方法?
  • 还是我在pom.xml某处做了一些愚蠢的事情?

任何提示?

[更新]也喜欢旗帜的形象,如果我父母这样设置

<bannerLeft> 
    <name>edcp</name> 
    <src>images/mylogo.png</src> 
</bannerLeft> 

该网站的子模块与指向错误的方向,在HTML中,看起来像..\..\<submodule>,不..\images\mylogo.png

+0

如果我在每个子模块下添加简单的site.xml,它现在工作正常 – 2011-05-13 02:59:49

+0

您可以回答自己的问题,并选择它是正确的。通过这种方式,从概览页面可以看出问题有解决方案。 – Jan 2011-05-16 08:22:06

+0

这是一个不是很好的解决方案,我仍然希望让人们给我更好的答案,而这个系统建议不要回答我自己的问题。 – 2011-05-18 03:03:43

回答

3

如果你想避免手动复制site.xml的每个子模块,然后使用maven-resources-plugin可能是一个解决方法:添加到您的父POM:

[...] 
<properties> 
    <site.basedir>${project.basedir}</site.basedir> 
</properties> 
[...] 
<build> 
<plugins> 
    <plugin> 
    <artifactId>maven-resources-plugin</artifactId> 
    <version>2.5</version> 
    <executions> 
     <execution> 
     <id>copy-sitedescriptor</id> 
     <!-- fetch site.xml before creating site documentation --> 
     <phase>pre-site</phase> 
     <goals> 
      <goal>copy-resources</goal> 
     </goals> 
     <configuration> 
      <outputDirectory>${basedir}/src/site/</outputDirectory> 
      <resources>   
      <resource>     
       <directory>${site.basedir}/src/site/</directory> 
       <includes> 
       <include>**/site.xml</include> 
       </includes> 
      </resource> 
      </resources>    
     </configuration>    
     </execution> 
    </executions> 
    </plugin>   

,这对每个子模块多金属氧酸盐:

<properties> 
    <site.basedir>${project.parent.basedir}</site.basedir> 
</properties> 

那么网站描述将从父项目到每个子模块(覆盖现有的描述符)复制在创建网站之前的文档。请注意,每个子模块中必须存在src/site目录才能生效。不是一个完美的解决方案,但可能比完整的手册更好。

+0

可能被接受的答案取代在这里:http://stackoverflow.com/questions/10848715/multi-模块-pom-creating-a-site-that-works – Stewart 2013-06-23 21:05:49

0

我正在使用一个小的Python脚本来创建模板中的所有site.xml文件。 Here is the gist

3

可以通过使用inherit属性继承父site.xml的菜单。

E.g,

<project> 
    .... 
    <body> 
    <menu name="Overview" inherit="top"> 
    <item name="Introduction" href="introduction.html"/> 
    </menu> 
    <menu name="Development" inherit="top"> 
     <item name="Getting started" href="designenv.html"/> 
     <item name="FAQ" href="designfaq.html" /> 
     <item name="Javadoc" href="apidocs/index.html" /> 
    </menu> 
    <menu ref="modules"/> 
    <menu ref="reports"/> 
</body> 
</project> 

现在OverviewDevelopment菜单都将被所有的子项目继承。

见多模块的网站了解更多详情Maven的文档, http://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html#Inheritance

1

试图生成一个多模块的Maven的网站,只是想分享我想出了一个解决方案时,我碰到这个偶然。

在你的父POM添加

<siteDirectory>${session.executionRootDirectory}/src/site</siteDirectory> 

到Maven站点插件配置。

这应该告诉所有的孩子poms从父目录获取他们的site.xml。

+0

但是,这将完全忽略子模块的特定内容。首先,我也认为这将是解决方案,但它做了一些稍微不同的事情。 – 2017-01-06 13:22:32