Index: src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java =================================================================== --- src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java (revision 661706) +++ src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java (working copy) @@ -56,6 +56,7 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.DefaultPluginManager; import org.apache.maven.plugin.javadoc.options.DocletArtifact; import org.apache.maven.plugin.javadoc.options.Group; import org.apache.maven.plugin.javadoc.options.JavadocPathArtifact; @@ -60,6 +61,7 @@ import org.apache.maven.plugin.javadoc.options.Group; import org.apache.maven.plugin.javadoc.options.JavadocPathArtifact; import org.apache.maven.plugin.javadoc.options.OfflineLink; +import org.apache.maven.plugin.javadoc.options.ResourcesArtifact; import org.apache.maven.plugin.javadoc.options.Tag; import org.apache.maven.plugin.javadoc.options.Taglet; import org.apache.maven.plugin.javadoc.options.TagletArtifact; @@ -73,6 +75,9 @@ import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; import org.apache.maven.wagon.PathUtils; +import org.codehaus.plexus.archiver.UnArchiver; +import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; @@ -219,6 +224,25 @@ private ArtifactResolver resolver; /** + * A list of artifacts containing resources which sould be copied into the + * javadoc output directory (like stylesheets, icons, etc.). + *
+ * Example: + *
+     * <resourcesArtifacts>
+ * <resourcesArtifact>
+ * <groupId>external.group.id</groupId>
+ * <artifactId>external-resources</artifactId>
+ * <version>1.0</version>
+ * </resourcesArtifact>
+ * </resourcesArtifacts> + *
+ * + * @parameter expression="${resourcesArtifacts}" + */ + private ResourcesArtifact[] resourcesArtifacts; + + /** * Factory for creating artifact objects * * @component @@ -1071,6 +1095,12 @@ */ private String windowtitle; + /** + * @component + */ + private ArchiverManager archiverManager; + + // ---------------------------------------------------------------------- // protected methods // ---------------------------------------------------------------------- @@ -1314,6 +1344,62 @@ throw new MavenReportException( "Unable to copy javadoc resources: " + e.getMessage(), e ); } } + + // ---------------------------------------------------------------------- + // Copy additional javadoc resources in artifacts + // ---------------------------------------------------------------------- + if ( resourcesArtifacts != null && resourcesArtifacts.length > 0 ) + { + + File target = javadocOutputDirectory; + + UnArchiver unArchiver; + try + { + unArchiver = archiverManager.getUnArchiver( "jar" ); + } + catch ( NoSuchArchiverException e ) + { + throw new MavenReportException( "Unable to extract resources artifact. No archiver for 'jar' available.", e ); + } + + for ( int i = 0; i < resourcesArtifacts.length; i++ ) + { + ResourcesArtifact item = resourcesArtifacts[i]; + + Artifact artifact; + + try + { + artifact = createAndResolveArtifact( item ); + } + catch ( ArtifactResolutionException e ) + { + throw new MavenReportException( "Unable to resolve artifact:" + item, e ); + } + catch ( ArtifactNotFoundException e ) + { + throw new MavenReportException( "Unable to find artifact:" + item, e ); + } + + unArchiver.setSourceFile( artifact.getFile() ); + unArchiver.setDestDirectory( target ); + + getLog().info( + "extracting contents of resources artifact: " + item.getGroupId() + ":" + + item.getArtifactId() + ":" + item.getVersion() ); + try + { + unArchiver.extract(); + } + catch ( Exception e ) + { + throw new MavenReportException( "extraction of resources failed. Artifact that failed was: " + + item, e ); + } + } + } + // ---------------------------------------------------------------------- // Wrap javadoc options @@ -2291,13 +2377,10 @@ List path = new ArrayList(); - Artifact artifact = factory.createArtifact( javadocArtifact.getGroupId(), javadocArtifact.getArtifactId(), - javadocArtifact.getVersion(), Artifact.SCOPE_COMPILE, "jar" ); try { - // Find the Javadoc Artifact in the local repo - resolver.resolve( artifact, remoteRepositories, localRepository ); + Artifact artifact = createAndResolveArtifact( javadocArtifact ); path.add( artifact.getFile().getAbsolutePath() ); // Find its transitive dependencies in the local repo @@ -2344,6 +2427,24 @@ } /** + * creates an {@link Artifact} representing the configured {@link JavadocPathArtifact} and resolves it. + * + * @param javadocArtifact the {@link JavadocPathArtifact} to resolve + * @return a resolved {@link Artifact} + * @throws ArtifactResolutionException if the resolution of the artifact failed. + * @throws ArtifactNotFoundException if the artifact hasn't been found. + */ + private Artifact createAndResolveArtifact( JavadocPathArtifact javadocArtifact ) + throws ArtifactResolutionException, ArtifactNotFoundException + { + Artifact artifact = factory.createArtifact( javadocArtifact.getGroupId(), javadocArtifact.getArtifactId(), + javadocArtifact.getVersion(), Artifact.SCOPE_COMPILE, "jar" ); + // Find the Javadoc Artifact in the local repo + resolver.resolve( artifact, remoteRepositories, localRepository ); + return artifact; + } + + /** * Method that adds/sets the java memory parameters in the command line execution. * * @param cmd the command line execution object where the argument will be added Index: src/main/mdo/javadocOptions.mdo =================================================================== --- src/main/mdo/javadocOptions.mdo (revision 632407) +++ src/main/mdo/javadocOptions.mdo (working copy) @@ -178,6 +178,13 @@ + ResourcesArtifact + A artifact containing resources. + 1.0.0 + JavadocPathArtifact + + + Taglet A Taglet parameter. 1.0.0 Index: pom.xml =================================================================== --- pom.xml (revision 661706) +++ pom.xml (working copy) @@ -259,6 +259,7 @@ src/it **/MJAVADOC-110/pom.xml + **/MJAVADOC-126/pom.xml **/MJAVADOC-137/pom.xml **/MJAVADOC-172/pom.xml **/MJAVADOC-180/pom.xml