题
我有一个有很多子模块的maven项目,我使用父pom来控制目录中的插件,如下所示
-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>
我跑完之后 mvn site:stage
在根(建议从 maven站点插件),父网页没问题,而 <sub-modules>\index.html
不包含任何菜单(没有项目信息和项目报告)
我也注意到如果我跑 mvn site
在子模块下,索引。html在左边不包含任何菜单,而单独的html存在于像pmd这样的目录中.html,许可证。html格式
- 我需要添加吗
src\site\site.xml
在每个子模块或其他更好的方式? - 还是我做了一些愚蠢的事
pom.xml
什么地方?
有什么暗示吗?
[更新]也喜欢横幅图像,如果我设置在父像这样
<bannerLeft>
<name>edcp</name>
<src>images/mylogo.png</src>
</bannerLeft>
在html中,指向错误方向的子模块的站点看起来像 ..\..\<submodule>
, ,不 ..\images\mylogo.png
解决方案
如果您想避免复制网站。xml到每个子模块手动,然后使用 maven-资源-插件 可能是一种解决方法:将此添加到您的父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>
这对你的每个子模块pom:
<properties>
<site.basedir>${project.parent.basedir}</site.basedir>
</properties>
然后在创建站点文档之前,站点描述符将从父项目复制到每个子模块(复盖现有描述符)。请注意,src/site目录必须存在于每个子模块中才能使此工作。不是一个完美的解决方案,但也许比一个完整的手动解决方案更好。
其他提示
可以从父级继承菜单 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>
现在这两个 Overview
和 Development
菜单将由所有子项目继承。
有关更多详细信息,请参阅多模块站点的Maven文档, http://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html#Inheritance
我在尝试生成一个多模块maven站点时偶然发现了这一点,只是想分享我想出的解决方案。
在你的父母pom添加
<siteDirectory>${session.executionRootDirectory}/src/site</siteDirectory>
到maven站点插件配置。
这应该告诉所有的孩子poms得到他们的网站。父目录中的xml。
我正在使用一个小的Python脚本来创建所有的 site.xml
模板中的文件。 这里是要点.