Index: D:/Java/maven-2.0/maven-components/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteMojo.java =================================================================== --- D:/Java/maven-2.0/maven-components/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteMojo.java (revision 331098) +++ D:/Java/maven-2.0/maven-components/maven-plugins/maven-site-plugin/src/main/java/org/apache/maven/plugins/site/SiteMojo.java (working copy) @@ -16,6 +16,8 @@ * limitations under the License. */ +import org.apache.maven.model.DistributionManagement; +import org.apache.maven.model.Site; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -81,7 +83,7 @@ * @required */ private File siteDirectory; - + /** * Alternative directory for xdoc source, useful for m1 to m2 migration * @@ -179,6 +181,15 @@ private MavenProject project; /** + * The reactor projects. + * + * @parameter expression="${reactorProjects}" + * @required + * @readonly + */ + private List reactorProjects; + + /** * @parameter expression="${reports}" * @required * @readonly @@ -195,6 +206,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { + if ( templateDirectory == null ) { siteRenderer.setTemplateClassLoader( SiteMojo.class.getClassLoader() ); @@ -351,6 +363,9 @@ generateIndexPage( siteDescriptor, locale, outputDirectory ); } + // TODO: Be good to generate a module's summary page thats referenced off the + // Modules menu item. + // Log if a user override a report file for ( Iterator it = generatedReportsFileName.iterator(); it.hasNext(); ) { @@ -387,36 +402,6 @@ copyDirectory( resourcesDirectory, outputDirectory ); } - // Copy the generated site in parent site if needed to provide module links - if ( addModules ) - { - MavenProject parentProject = project.getParent(); - if ( parentProject != null ) - { - // TODO Handle user plugin configuration -/* TODO: Not working, and would be better working as a top-level aggregation rather than pushing from the subprojects... - File basedir = parentProject.getBasedir(); - if ( basedir != null ) - { - String path = parentProject.getBuild().getDirectory() + "/site/" + project.getArtifactId(); - File parentSiteDir = new File( basedir, path ); - - if ( !parentSiteDir.exists() ) - { - parentSiteDir.mkdirs(); - } - - File siteDir = new File( outputDirectory ); - FileUtils.copyDirectoryStructure( siteDir, parentSiteDir ); - } - else - { - getLog().info( "Not using parent as it was not located on the filesystem" ); - } -*/ - } - } - if ( generatedSiteDirectory.exists() ) { siteRenderer.render( generatedSiteDirectory, outputDirectory, siteDescriptor, template, attributes, @@ -618,56 +603,137 @@ * * @param locale the locale wanted * @return a XML menu for modules + * @throws MojoExecutionException */ -/* private String getModulesMenu( Locale locale ) + private String getModulesMenu( Locale locale ) throws MojoExecutionException { + StringBuffer buffer = new StringBuffer(); + buffer.append( "
\n" ); return buffer.toString(); } -*/ + /** * Generate a menu for the parent project * * @param locale the locale wanted * @return a XML menu for the parent project */ -/* private String getProjectParentMenu( Locale locale ) + private String getProjectParentMenu( Locale locale ) { StringBuffer buffer = new StringBuffer(); - buffer.append( "\n" ); + if ( parentSite == null ) + { + getLog().warn( "Project: " + parent.getArtifactId() + " has no distribution management"); + } + else + { + + String parentUrl = parentSite.getUrl(); + + if ( parentUrl != null ) + { + + parentUrl += "/index.html"; + + buffer.append( "\n" ); + + } + } + + } + return buffer.toString(); } -*/ + /** * @param reports a list of reports * @param locale the current locale @@ -717,17 +783,14 @@ if ( project.getParent() != null ) { - /* See the Not working section*/ - //props.put( "parentProject", getProjectParentMenu( locale ) ); + props.put( "parentProject", getProjectParentMenu( locale ) ); } - if ( addModules ) + // we require child modules and reactors to process module menu + + if ( ( addModules && reactorProjects.size() > 1 && project.getModules().size() > 0 ) ) { - if ( project.getModules() != null && project.getModules().size() > 0 ) - { - /* See the Not working section*/ - //props.put( "modules", getModulesMenu( locale ) ); - } + props.put( "modules", getModulesMenu( locale ) ); } // TODO: interpolate ${project.*} in general @@ -755,7 +818,8 @@ return siteDescriptorContent; } - /** + + /** * Generate an index page. * * @param siteDescriptor