I have a maven project with lots of sub-modules, and I use parent pom to control the plugins the directory like below
-pom.xml (parent pom)
+- submodule1
+- submodule2
+- src\site\site.xml
therefore src\site\site.xml
contains the customized menu like below
<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>
After I run mvn site:stage
in root (suggested from maven site plugin), the parent webpage is fine, while the <sub-modules>\index.html
doesn't contain any menu (no project info & project report)
Also I notice if I run mvn site
under sub-modules, the index.html doesn't contain any menu in left, while the individual html exist in directory like pmd.html, license.html
src\site\site.xml
in each sub-module or other better way ?pom.xml
somewhere ?Any hints ?
[update] also like for banner image, if I set in parent like this
<bannerLeft>
<name>edcp</name>
<src>images/mylogo.png</src>
</bannerLeft>
The site for sub-module with points to wrong direction, in html, looks like ..\..\<submodule>
, not ..\images\mylogo.png
If you would like to avoid copying the site.xml to each submodule manually, then using the maven-resources-plugin could be a workaround: Add this to your parent 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>
and this to each of your submodule poms:
<properties>
<site.basedir>${project.parent.basedir}</site.basedir>
</properties>
Then the site descriptor will be copied from the parent project to each submodule (overwriting existing descriptors) before the site documentation is created. Please note that the src/site directory must exist in each submodule to make this work. Not a perfect solution, but maybe better than a complete manual one.
It's possible to inherit menus from the parent site.xml
by using the inherit
attribute.
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>
Now both the Overview
and Development
menus will be inherited by all sub-projects.
See the Maven documentation for multi-module sites for more details, http://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html#Inheritance
I stumbled across this when trying to generate a multi module maven site and just wanted to share a solution I came up with.
In your parent pom add
<siteDirectory>${session.executionRootDirectory}/src/site</siteDirectory>
to the maven site plugin configuration.
That should tell all the child poms to get their site.xml from the parent directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With