My multi-module Maven project looks like:
/foo
pom.xml
开发者_如何学C /foo-parent
/foo-core
/foo-something
/src
/site
Pay attention that foo
is not a parent project, but foo-parent
is (for foo-core
and foo-something
). foo
is not inheriting from foo-parent
. Site configuration is stored in foo
. All other sub-modules don't know anything about project site and don't have <distributionManagement>
. mvn site works perfect, and now I'm running mvn site-deploy
:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:2.0.1:deploy
(default-deploy) on project foo-parent: Missing site information in the
distribution management element in the project.. -> [Help 1]
Maven is trying to site-deploy
every sub-module individually?? Is it a correct behavior?
In regards to your distribution config question:
Maven won't let a child module be the parent pom of the top level pom.xml. That's Maven's way of telling you that you not structuring you project to convention.
You'll have to make foo's pom.xml a parent pom for all modules in the whole project.
The workaround for what you are trying to structure, have the modules that depend on foo-parent, list foo-parent's pom.xml in the parent section of their pom. Then have foo-parent list foo's pom.xml in its parent section. You can get away with having foo-parent be the parent pom.xml for all the other modules because all modules are peers to each other in structure layout.
The top level pom.xml should only contain the necessary information to be shared between all modules.
In regards to your site-deploy question:
Maven tries to deploy every site individually for each module because of the top level /src/site/site.xml you have setup. But this is also partly due to the fact that your probably running site-deploy from the top level (foo). If you only want the documentation for foo-parent, run site-deploy only on foo-parent. However, you may not get any of the documentation for the other modules linked into foo-parent's site documentation.
P.S. Better read up on Maven 3. There are some very significant changes to the site documentation generation coming!
EDIT: Links for reference:
- Maven 3 Compatibility Notes
- Maven 3 Site Plugin Notes
精彩评论