[
http://jira.codehaus.org/browse/MSITE-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=137655#action_137655
]
Doron Solomon commented on MSITE-163:
-------------------------------------
I've been looking into this issue and have come up with a proposed solution ...
I don't presume to know enough about the way the plugin should work to say it's
the best solution, so I hope that someone who knows more than I do can comment.
In version 2.0-beta-6, the problem is in the method {{populateModules}} in the
class {{org.apache.maven.plugins.site.AbstractSiteMojo}}. In this method two
booleans are checked - {{keepInheritedRefs}} and {{menu.isInheritAsRef()}}. If
either of these is false, then the modules are populated (otherwise, the
element is left alone to inherit from a parent). If the project has no
modules, then the {{<menu ref="modules">}} element is removed by calling method
{{decorationModel.removeMenuRef}}. However, this seems to go against the
purpose of the {{keepInhertiedRefs}} boolean ... if we want to keep inherited
refs then shouldn't the element remain in the site descriptor, even if there
are no modules of *this* POM?
I tried surrounding the call to {{decorationModel.removeMenuRef}} with an if
statement:
{code:title=AbstractSiteMojo.java}
if ( !keepInheritedRefs )
{
decorationModel.removeMenuRef( "modules" );
}
{code}
The problem with this is that it now keeps the {{<menu ref="modules">}} element
even if no inherit attribute is set, which again (I believe) goes against the
purpose of this attribute. So I was able to get the {{<menu ref="modules">}}
element to remain in the installed/deployed site descriptor ONLY if the element
contains an inherit attribute by changing the above code to:
{code:title=AbstractSiteMojo.java}
if ( !keepInheritedRefs || menu.getInherit() == null )
{
decorationModel.removeMenuRef( "modules" );
}
{code}
This made me stop and think about the {{keepInheritedRefs}} flag. I'm not sure
what its purpose is, but it seems to me that it should be set to true or false
depending on whether or not {{menu.getInherit()}} is null (i.e. set to false if
null). But since I can't be certain of the purpose of {{keepInheritedRefs}} I
can't say for sure that this is correct.
I believe that all of the above would also apply to the
{{populateProjectParentMenu}} method that deals with the {{<menu
ref="parent">}} element, although I have not tested this.
Finally, it is worth noting that in the trunk the {{populateModules}} method
has moved to the maven-doxia-tools artifact (groupId org.apache.maven.shared)
into the class {{org.apache.maven.doxia.tools.DefaultSiteTool}} (the method is
also defined in the {{SiteTool}} interface). Perhaps this issue should be
moved to that project?
> The modules menu is not inherited
> ---------------------------------
>
> Key: MSITE-163
> URL: http://jira.codehaus.org/browse/MSITE-163
> Project: Maven 2.x Site Plugin
> Issue Type: Bug
> Components: inheritance
> Affects Versions: 2.0-beta-4
> Environment: ubuntu linux / debian linux
> Reporter: Andrew Williams
> Fix For: 2.0-beta-8
>
>
> if I have a site.xml in a parent project that contains the line <menu
> ref="modules" inherit="top" /> it is not inherited by child projects.
> <menu ref="reports" inherit="top" /> works, as does parent.
> This happens when the parent project has no modules of its own.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira