4

If I have a multi-module project, how can I inherit a menu from my parent POM? The project layout is:

main <-- main project which just contains modules
   parent   <-- parent POM
   ext      <-- 3rd party code

I tried this in my parent's site.xml:

<menu name="Projects">
   <item name="Main Project" href="${web-root}/" collapse="false">
      <item name="Parent POM" href="${web-root}/parent/" />
      <item name="3rd Party" href="${web-root}/ext/">
   </item>
</menu>

and in the site.xml of ext, I used:

<menu name="Projects" inherit="top" />

I get the menu but no links.

I also tried to define the menu in the main project's site.xml but the result is the same.

yegor256
  • 102,010
  • 123
  • 446
  • 597
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820

1 Answers1

4

I noticed three things:

First notice: You have to specify the inherit attribute in the site.xml of the parent POM, not in the child POM. And in the site.xml of the child POM, do not re-specify the menu to be inherited at all.

site.xml of the parent:

<menu name="Projects" inherit="top">
  <item ...>
  </item>
</menu>

site.xml of the child: no menu definition with name="Projects".

Second notice: The links for your project structure can be automatically constructed:

site.xml of the parent:

<!-- Inherit this menu for sub modules. -->
<menu ref="parent" inherit="top" />

<!-- Inherit this menu for sub modules. -->
<menu name="Sub Modules" ref="modules" inherit="bottom" />

This will generate all inter-module links for you.

Third notice: Site descriptors are inherited along the same lines as project descriptors are. If your module "ext" should inherit menu entries in the site descriptor from other modules, ext must have "main" or "parent" as parent in the pom.xml.

Martin Ackermann
  • 1,066
  • 10
  • 15