Index: src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java =================================================================== --- src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java (revision 607765) +++ src/main/java/org/apache/maven/plugins/site/AbstractSiteMojo.java (working copy) @@ -88,6 +88,16 @@ protected File siteDirectory; /** + * The root directory of the currently executed project. The whole purpose of this parameter is to retrieve the + * relative path to the site directory from the parameter {@link #siteDirectory}, e.g. "src/site". + * + * @parameter expression="${basedir}" + * @required + * @readonly + */ + private File baseDirectory; + + /** * The maven project. * * @parameter expression="${project}" @@ -250,19 +260,33 @@ /** * Get the path of the site descriptor for a given locale. * - * @param basedir the base dir + * @param basedir the base directory of the project whose site descriptor is to retrieve * @param locale the locale * @return the site descriptor path */ protected File getSiteDescriptorFile( File basedir, Locale locale ) { - String relativePath = getRelativePath( siteDirectory.getAbsolutePath(), basedir.getAbsolutePath() ); + /* + * FIXME: This is a hacky fix for MSITE-91: The location of the site descriptor is best understood as a + * project-specific setting and should therefore be configured via a dedicated POM element, e.g. + * ${project.reporting.siteDirectory}, that the super POM defaults to "src/site". Specifying the site directory + * in the plugin configuration raises the following problem for the plugin: When the site descriptors for parent + * projects need to be retrieved, where should the plugin look? The plugin only knows about the site directory + * of the currently executed sub project but ancestor projects may use a different location for their site.xml. + * For now, we assume that all ancestor projects from which the current project inherits use the same location + * for the site.xml (relative to their base directories). When this architectural design flaw gets hopefully + * fixed in Maven 2.1, the signature of this method should be changed to ( MavenProject, Locale ) such that the + * site directory can be retrieved from the desired POM. The mojo parameters siteDirectory and baseDirectory + * should be deleted then. + */ + String relativePath = getRelativePath( siteDirectory.getAbsolutePath(), baseDirectory.getAbsolutePath() ); + File siteDir = new File( basedir, relativePath ); - File siteDescriptor = new File( relativePath, "site_" + locale.getLanguage() + ".xml" ); + File siteDescriptor = new File( siteDir, "site_" + locale.getLanguage() + ".xml" ); if ( !siteDescriptor.exists() ) { - siteDescriptor = new File( relativePath, "site.xml" ); + siteDescriptor = new File( siteDir, "site.xml" ); } return siteDescriptor; } @@ -789,8 +813,13 @@ { try { + String relativePath = aProject.getModel().getParent().getRelativePath(); + if ( new File( relativePath ).isDirectory() ) + { + relativePath = new File( relativePath, "pom.xml" ).getPath(); + } MavenProject mavenProject = mavenProjectBuilder.build( - new File( aProject.getBasedir(), aProject.getModel().getParent().getRelativePath() ), + new File( aProject.getBasedir(), relativePath ), localRepository, null ); if ( mavenProject.getGroupId().equals( origParent.getGroupId() ) && mavenProject.getArtifactId().equals( origParent.getArtifactId() )