maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1747974 - /maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
Date Sun, 12 Jun 2016 10:18:45 GMT
Author: rfscholte
Date: Sun Jun 12 10:18:45 2016
New Revision: 1747974

URL: http://svn.apache.org/viewvc?rev=1747974&view=rev
Log:
[MJAVADOC-456] Upgrade to Maven3 plugin
replace old artifactResolver.transitive with dependencyResolver

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java?rev=1747974&r1=1747973&r2=1747974&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractJavadocMojo.java
Sun Jun 12 10:18:45 2016
@@ -102,7 +102,12 @@ import org.apache.maven.settings.Setting
 import org.apache.maven.shared.artifact.DefaultArtifactCoordinate;
 import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter;
 import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter;
+import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter;
 import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.dependency.DefaultDependencyCoordinate;
+import org.apache.maven.shared.dependency.resolve.DependencyResolver;
+import org.apache.maven.shared.dependency.resolve.DependencyResolverException;
 import org.apache.maven.shared.invoker.MavenInvocationException;
 import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
@@ -307,6 +312,9 @@ public abstract class AbstractJavadocMoj
     
     @Component
     private org.apache.maven.shared.artifact.resolve.ArtifactResolver artifactResolver;
+    
+    @Component
+    private DependencyResolver dependencyResolver;
 
     /**
      * Project builder
@@ -3394,41 +3402,28 @@ public abstract class AbstractJavadocMoj
             Artifact artifact = createAndResolveArtifact( javadocArtifact );
             path.add( artifact.getFile().getAbsolutePath() );
 
-            // Find its transitive dependencies in the local repo
-            MavenProject artifactProject =
-                mavenProjectBuilder.build( artifact, session.getProjectBuildingRequest()
).getProject();
-            Set<Artifact> dependencyArtifacts = artifactProject.createArtifacts( factory,
null, null );
-            if ( !dependencyArtifacts.isEmpty() )
-            {
-                ArtifactResolutionResult result =
-                    resolver.resolveTransitively( dependencyArtifacts, artifactProject.getArtifact(),
-                                                  artifactProject.getRemoteArtifactRepositories(),
localRepository,
-                                                  artifactMetadataSource );
-
-                for ( Artifact a : result.getArtifacts() )
-                {
-                    path.add( a.getFile().getAbsolutePath() );
-                }
+            DefaultDependencyCoordinate coordinate = new DefaultDependencyCoordinate();
+            coordinate.setGroupId( javadocArtifact.getGroupId() );
+            coordinate.setArtifactId( javadocArtifact.getArtifactId() );
+            coordinate.setVersion( javadocArtifact.getVersion() );
+
+            Iterable<ArtifactResult> deps =
+                dependencyResolver.resolveDependencies( session.getProjectBuildingRequest(),
coordinate,
+                                                        ScopeFilter.including( "compile",
"provided" ) );
+            for ( ArtifactResult a : deps )
+            {
+                path.add( a.getArtifact().getFile().getAbsolutePath() );
             }
 
             return path;
         }
-        catch ( ArtifactResolutionException e )
+        catch ( ArtifactResolverException e )
         {
             throw new MavenReportException( "Unable to resolve artifact:" + javadocArtifact,
e );
         }
-        catch ( ArtifactNotFoundException e )
+        catch ( DependencyResolverException e )
         {
-            throw new MavenReportException( "Unable to find artifact:" + javadocArtifact,
e );
-        }
-        catch ( ProjectBuildingException e )
-        {
-            throw new MavenReportException( "Unable to build the Maven project for the artifact:"
+ javadocArtifact,
-                                            e );
-        }
-        catch ( ArtifactResolverException e )
-        {
-            throw new MavenReportException( "Unable to resolve artifact:" + javadocArtifact,
e );
+            throw new MavenReportException( "Unable to resolve dependencies for:" + javadocArtifact,
e );
         }
     }
 



Mime
View raw message