2011-05-12 84 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