1

My multi-module Maven project looks like:

/foo
  pom.xml
  /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?

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • What is your sub-projects inheritance model/layout? – Ali Shakiba Dec 17 '10 at 22:34
  • @JohnS I updated the question. `foo-parent` is parent of `foo-core` and `foo-something`. – yegor256 Dec 18 '10 at 07:50
  • Check out my answer here: http://stackoverflow.com/questions/4441685/multi-module-maven-project-with-parent-pom-and-svn-layout/4442077#4442077 Does it help you? – Ali Shakiba Dec 18 '10 at 10:06
  • I can't understand why you have your site in a parent directory? – Ali Shakiba Dec 18 '10 at 10:11
  • @JohnS Where should I place my site? It is now in "foo" module. Which module should I place it into? – yegor256 Dec 18 '10 at 15:32
  • Create a foo-site directory beside your other foo-xxx directories and put src/site and its pom.xml there so that other modules does not consider it as parent module and do not inherit its site plugin declaration. – Ali Shakiba Dec 18 '10 at 20:09
  • @JohnS: There's nothing wrong with having a top level site.xml file for the project, even if he has a module that is the 'parent' project. The site.xml is there so that when the site documentation when generated is navigable between modules. – jgifford25 Dec 20 '10 at 19:44

1 Answers1

3

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:

jgifford25
  • 2,164
  • 1
  • 14
  • 17
  • Can you give a link on where to read about site creation in Maven 3? I still can't understand what is the **correct** way of creating/deploying site(s) in multi-module project... – yegor256 Dec 21 '10 at 14:18
  • @Vincenzo: Added the links to the answer. – jgifford25 Dec 21 '10 at 15:56
  • Links are now [Maven 3 Compatibility Notes](https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes?src=search) and [Maven 3 Site Plugin Notes](https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+and+site+plugin?src=search) – MTranchant Dec 30 '15 at 10:24