svn commit: r1801785 - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugins/javadoc/ src/main/java/org/apache/maven/plugins/javadoc/resolver/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

svn commit: r1801785 - in /maven/plugins/trunk/maven-javadoc-plugin: ./ src/main/java/org/apache/maven/plugins/javadoc/ src/main/java/org/apache/maven/plugins/javadoc/resolver/

rfscholte
Author: rfscholte
Date: Wed Jul 12 22:30:43 2017
New Revision: 1801785

URL: http://svn.apache.org/viewvc?rev=1801785&view=rev
Log:
[MJAVADOC-456] Upgrade to Maven3 plugin
No need to resolve transitive dependencies twice

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/pom.xml
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/pom.xml?rev=1801785&r1=1801784&r2=1801785&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/pom.xml Wed Jul 12 22:30:43 2017
@@ -170,7 +170,7 @@ under the License.
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-artifact-transfer</artifactId>
-      <version>3.0.0-SNAPSHOT</version>
+      <version>0.9.1</version>
     </dependency>
 
     <!-- Doxia -->

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java?rev=1801785&r1=1801784&r2=1801785&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java Wed Jul 12 22:30:43 2017
@@ -2405,7 +2405,7 @@ public abstract class AbstractJavadocMoj
     private SourceResolverConfig getDependencySourceResolverConfig()
     {
         return configureDependencySourceResolution(
-                        new SourceResolverConfig( project, localRepository,
+                        new SourceResolverConfig( project, session.getProjectBuildingRequest(),
                                                   sourceDependencyCacheDir ).withReactorProjects( reactorProjects ) );
     }
 

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java?rev=1801785&r1=1801784&r2=1801785&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java Wed Jul 12 22:30:43 2017
@@ -26,7 +26,6 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -37,11 +36,8 @@ import org.apache.maven.artifact.Artifac
 import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.plugins.javadoc.options.JavadocOptions;
 import org.apache.maven.plugins.javadoc.options.io.xpp3.JavadocOptionsXpp3Reader;
@@ -50,6 +46,8 @@ import org.apache.maven.plugins.javadoc.
 import org.apache.maven.plugins.javadoc.ResourcesBundleMojo;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.artifact.filter.resolve.transform.ArtifactIncludeFilterTransformer;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
 import org.apache.maven.shared.dependencies.resolve.DependencyResolver;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.UnArchiver;
@@ -373,9 +371,6 @@ public final class ResourceResolver exte
         // resolve transitively...this is just used to aggregate resolution failures into a single
         // exception.
         final Set<Artifact> artifactSet = new LinkedHashSet<Artifact>( artifacts );
-        final Artifact pomArtifact = config.project().getArtifact();
-        final ArtifactRepository localRepo = config.localRepository();
-        final List<ArtifactRepository> remoteRepos = config.project().getRemoteArtifactRepositories();
 
         final ArtifactFilter filter;
         if ( config.filter() != null )
@@ -387,28 +382,23 @@ public final class ResourceResolver exte
             filter = null;
         }
         
-        ArtifactFilter resolutionFilter = null;
-        if ( filter != null )
-        {
-            // Wrap the filter in a ProjectArtifactFilter in order to always include the pomArtifact for resolution.
-            // NOTE that this is necessary, b/c the -sources artifacts are added dynamically to the pomArtifact
-            // and the resolver also checks the dependency trail with the given filter, thus the pomArtifact has
-            // to be explicitly included by the filter, otherwise the -sources artifacts won't be resolved.
-            resolutionFilter = new ProjectArtifactFilter( pomArtifact, filter );
-        }
-
-        Map<String, Artifact> managed = config.project().getManagedVersionMap();
-        
-        final ArtifactResolutionResult resolutionResult = resolver.resolveTransitively(
-                artifactSet, pomArtifact, managed, localRepo, remoteRepos, artifactMetadataSource, resolutionFilter );
-
         final List<String> result = new ArrayList<String>( artifacts.size() );
-        for ( final Artifact a : (Collection<Artifact>) resolutionResult.getArtifacts() )
+        for ( final Artifact a : artifactSet )
         {
             if ( !validClassifiers.contains( a.getClassifier() ) || ( filter != null && !filter.include( a ) ) )
             {
                 continue;
             }
+            
+            Artifact resolvedArtifact;
+            try
+            {
+                resolvedArtifact = resolver.resolveArtifact( config.getBuildingRequest(), a ).getArtifact();
+            }
+            catch ( ArtifactResolverException e1 )
+            {
+                continue;
+            }
 
             final File d =
                 new File( config.outputBasedir(), a.getArtifactId() + "-" + a.getVersion() + "-" + a.getClassifier() );
@@ -423,7 +413,7 @@ public final class ResourceResolver exte
                 final UnArchiver unArchiver = archiverManager.getUnArchiver( a.getType() );
 
                 unArchiver.setDestDirectory( d );
-                unArchiver.setSourceFile( a.getFile() );
+                unArchiver.setSourceFile( resolvedArtifact.getFile() );
 
                 unArchiver.extract();
 

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java?rev=1801785&r1=1801784&r2=1801785&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java (original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugins/javadoc/resolver/SourceResolverConfig.java Wed Jul 12 22:30:43 2017
@@ -22,8 +22,8 @@ package org.apache.maven.plugins.javadoc
 import java.io.File;
 import java.util.List;
 
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.artifact.filter.resolve.AndFilter;
 
 /**
@@ -31,6 +31,7 @@ import org.apache.maven.shared.artifact.
  */
 public class SourceResolverConfig
 {
+    private ProjectBuildingRequest buildingRequest;
 
     private final MavenProject project;
 
@@ -44,18 +45,16 @@ public class SourceResolverConfig
 
     private boolean testSourceIncluded;
 
-    private final ArtifactRepository localRepository;
-
     /**
      * @param project {@link MavenProject}
-     * @param localRepository {@link ArtifactRepository}
+     * @param buoildingRequest {@link ProjectBuildingRequest}
      * @param outputBasedir The output base directory.
      */
-    public SourceResolverConfig( final MavenProject project, final ArtifactRepository localRepository,
+    public SourceResolverConfig( final MavenProject project, final ProjectBuildingRequest buildingRequest,
                                  final File outputBasedir )
     {
         this.project = project;
-        this.localRepository = localRepository;
+        this.buildingRequest = buildingRequest;
         this.outputBasedir = outputBasedir;
     }
 
@@ -124,11 +123,11 @@ public class SourceResolverConfig
     }
 
     /**
-     * @return {@link ArtifactRepository}
+     * @return {@link ProjectBuildingRequest}
      */
-    public ArtifactRepository localRepository()
+    public ProjectBuildingRequest getBuildingRequest()
     {
-        return localRepository;
+        return buildingRequest;
     }
 
     /**


Loading...