多模块的maven站点

Lar*_*Cai 7 maven-2 maven-site-plugin

我有一个包含大量子模块的maven项目,我使用父pom来控制插件目录,如下所示

-pom.xml (parent pom)
 +- submodule1
 +- submodule2
 +- src\site\site.xml
Run Code Online (Sandbox Code Playgroud)

因此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>
Run Code Online (Sandbox Code Playgroud)

在我运行mvn site:stageroot(从maven网站插件建议)后,父网页很好,<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>
Run Code Online (Sandbox Code Playgroud)

在html中,指向错误方向的子模块的站点看起来像..\..\<submodule>,而不是..\images\mylogo.png

小智 5

如果您想避免手动将 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>        
Run Code Online (Sandbox Code Playgroud)

并将其添加到每个子模块 poms 中:

<properties>
    <site.basedir>${project.parent.basedir}</site.basedir>
</properties>
Run Code Online (Sandbox Code Playgroud)

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


flu*_*y88 5

可以site.xml使用该inherit属性从父级继承菜单。

例如,

<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>
Run Code Online (Sandbox Code Playgroud)

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

有关更多详细信息,请参阅多模块站点的 Maven 文档, http://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html#Inheritance