maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1687370 - in /maven/shared/trunk/maven-dependency-tree/src: it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ main/java/org/apache/maven/shared/dependency/graph/ main/java/org/apache/maven/shared/dependency/graph/int...
Date Wed, 24 Jun 2015 21:01:25 GMT
Author: rfscholte
Date: Wed Jun 24 21:01:25 2015
New Revision: 1687370

URL: http://svn.apache.org/r1687370
Log:
[MSHARED-422] Change DependencyGraphBuilder method signatures
small bugfix in getDependencyArtifact(); When using RepositoryUtils.toArtifact() the scope
is ignored

Modified:
    maven/shared/trunk/maven-dependency-tree/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
    maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
    maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
    maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
    maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java

Modified: maven/shared/trunk/maven-dependency-tree/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java?rev=1687370&r1=1687369&r2=1687370&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/it/reactor/resolve-extension/src/main/java/org/apache/maven/its/deptree/ResolveDependenciesLifecycleParticipant.java
Wed Jun 24 21:01:25 2015
@@ -22,7 +22,9 @@ package org.apache.maven.its.deptree;
 import org.apache.maven.AbstractMavenLifecycleParticipant;
 import org.apache.maven.MavenExecutionException;
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
 import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
 import org.codehaus.plexus.component.annotations.Component;
@@ -66,6 +68,11 @@ public final class ResolveDependenciesLi
 
         for ( MavenProject project : projects )
         {
+            ProjectBuildingRequest buildingRequest =
+                new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+            
+            buildingRequest.setProject( project );
+            
             log.info( "building dependency graph for project " + project.getArtifact() );
 
             File resolved = new File( basedir, "resolved-" + project.getArtifactId() + ".txt"
);
@@ -73,7 +80,7 @@ public final class ResolveDependenciesLi
             {
                 log.info( "building with reactor projects" );
                 // No need to filter our search. We want to resolve all artifacts.
-                dependencyGraphBuilder.buildDependencyGraph( project, null, projects );
+                dependencyGraphBuilder.buildDependencyGraph( buildingRequest, null, projects
);
             }
             catch ( DependencyGraphBuilderException e )
             {
@@ -84,7 +91,7 @@ public final class ResolveDependenciesLi
             {
                 log.info( "building without reactor projects" );
                 // resolution without reactor projects, to check that it is not possible
at this point
-                dependencyGraphBuilder.buildDependencyGraph( project, null );
+                dependencyGraphBuilder.buildDependencyGraph( buildingRequest, null );
             }
             catch ( DependencyGraphBuilderException e )
             {

Modified: maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java?rev=1687370&r1=1687369&r2=1687370&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/DependencyGraphBuilder.java
Wed Jun 24 21:01:25 2015
@@ -21,6 +21,7 @@ package org.apache.maven.shared.dependen
 
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
 
 import java.util.Collection;
 
@@ -35,12 +36,12 @@ public interface DependencyGraphBuilder
     /**
      * Build the dependency graph.
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @return the dependency graph
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
-    DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter )
+    DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter )
         throws DependencyGraphBuilderException;
 
     /**
@@ -51,13 +52,13 @@ public interface DependencyGraphBuilder
      * artifacts but only the poms), probably this hack wouldn't be necessary even for people
requiring
      * the dependency graph before compiling. TODO: for Maven 3, use Aether to collect dependencies.</p>
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @param reactorProjects Collection of those projects contained in the reactor (can
be <code>null</code>).
      * @return the dependency graph
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
-    DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+    DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter,
                                          Collection<MavenProject> reactorProjects )
         throws DependencyGraphBuilderException;
 }

Modified: maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java?rev=1687370&r1=1687369&r2=1687370&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/DefaultDependencyGraphBuilder.java
Wed Jun 24 21:01:25 2015
@@ -21,6 +21,7 @@ package org.apache.maven.shared.dependen
 
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
 import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
 import org.apache.maven.shared.dependency.graph.DependencyNode;
@@ -54,16 +55,16 @@ public class DefaultDependencyGraphBuild
     /**
      * Builds a dependency graph.
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @return DependencyNode containing the dependency graph.
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
     @Override
-    public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter
)
+    public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter )
         throws DependencyGraphBuilderException
     {
-        return buildDependencyGraph( project, filter, null );
+        return buildDependencyGraph( buildingRequest, filter, null );
     }
 
     /**
@@ -76,7 +77,7 @@ public class DefaultDependencyGraphBuild
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
     @Override
-    public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+    public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter,
                                                 Collection<MavenProject> reactorProjects
)
         throws DependencyGraphBuilderException
     {
@@ -86,10 +87,16 @@ public class DefaultDependencyGraphBuild
 
             DependencyGraphBuilder effectiveGraphBuilder =
                 (DependencyGraphBuilder) container.lookup( DependencyGraphBuilder.class.getCanonicalName(),
hint );
-            getLogger().debug( "building " + hint + " dependency graph for " + project.getId()
+ " with "
-                                   + effectiveGraphBuilder.getClass().getSimpleName() );
+            
+            if ( getLogger().isDebugEnabled() )
+            {
+                MavenProject project = buildingRequest.getProject();
+                
+                getLogger().debug( "building " + hint + " dependency graph for " + project.getId()
+ " with "
+                                + effectiveGraphBuilder.getClass().getSimpleName() );
+            }
 
-            return effectiveGraphBuilder.buildDependencyGraph( project, filter, reactorProjects
);
+            return effectiveGraphBuilder.buildDependencyGraph( buildingRequest, filter, reactorProjects
);
         }
         catch ( ComponentLookupException e )
         {

Modified: maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java?rev=1687370&r1=1687369&r2=1687370&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven31DependencyGraphBuilder.java
Wed Jun 24 21:01:25 2015
@@ -64,38 +64,37 @@ public class Maven31DependencyGraphBuild
     /**
      * Builds the dependency graph for Maven 3.1+.
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @return DependencyNode containing the dependency graph.
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
     @Override
-    public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter
)
+    public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter )
         throws DependencyGraphBuilderException
     {
-        return buildDependencyGraph( project, filter, null );
+        return buildDependencyGraph( buildingRequest, filter, null );
     }
 
     /**
      * Builds the dependency graph for Maven 3.1+, eventually hacking for collecting projects
from
      * reactor not yet built.
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @param reactorProjects Collection of those projects contained in the reactor (can
be <code>null</code>).
      * @return DependencyNode containing the dependency graph.
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
     @Override
-    public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+    public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter,
                                                 Collection<MavenProject> reactorProjects
)
         throws DependencyGraphBuilderException
     {
-        ProjectBuildingRequest projectBuildingRequest =
-            (ProjectBuildingRequest) Invoker.invoke( project, "getProjectBuildingRequest"
);
-
+        MavenProject project = buildingRequest.getProject();
+        
         RepositorySystemSession session =
-            (RepositorySystemSession) Invoker.invoke( projectBuildingRequest, "getRepositorySession"
);
+            (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession"
);
 
         /*
          * if ( Boolean.TRUE != ( (Boolean) session.getConfigProperties().get(
@@ -188,7 +187,12 @@ public class Maven31DependencyGraphBuild
         
         try
         {
-            return (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact", org.eclipse.aether.artifact.Artifact.class,
artifact );
+            Artifact mavenArtifact = (Artifact) Invoker.invoke( RepositoryUtils.class, "toArtifact",
+                                              org.eclipse.aether.artifact.Artifact.class,
artifact );
+            
+            mavenArtifact.setScope( dep.getScope() );
+            
+            return mavenArtifact;
         }
         catch ( DependencyGraphBuilderException e )
         {

Modified: maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java?rev=1687370&r1=1687369&r2=1687370&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/graph/internal/Maven3DependencyGraphBuilder.java
Wed Jun 24 21:01:25 2015
@@ -63,38 +63,37 @@ public class Maven3DependencyGraphBuilde
     /**
      * Builds the dependency graph for Maven 3.
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @return DependencyNode containing the dependency graph.
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
     @Override
-    public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter
)
+    public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter )
         throws DependencyGraphBuilderException
     {
-        return buildDependencyGraph( project, filter, null );
+        return buildDependencyGraph( buildingRequest, filter, null );
     }
 
     /**
      * Builds the dependency graph for Maven 3, eventually hacking for collecting projects
from
      * reactor not yet built.
      *
-     * @param project the project
+     * @param buildingRequest the buildingRequest
      * @param filter artifact filter (can be <code>null</code>)
      * @param reactorProjects Collection of those projects contained in the reactor (can
be <code>null</code>).
      * @return DependencyNode containing the dependency graph.
      * @throws DependencyGraphBuilderException if some of the dependencies could not be resolved.
      */
     @Override
-    public DependencyNode buildDependencyGraph( MavenProject project, ArtifactFilter filter,
+    public DependencyNode buildDependencyGraph( ProjectBuildingRequest buildingRequest, ArtifactFilter
filter,
                                                 Collection<MavenProject> reactorProjects
)
         throws DependencyGraphBuilderException
     {
-        ProjectBuildingRequest projectBuildingRequest =
-            (ProjectBuildingRequest) Invoker.invoke( project, "getProjectBuildingRequest"
);
+        MavenProject project = buildingRequest.getProject();
 
         DependencyResolutionRequest request =
-            new DefaultDependencyResolutionRequest( project, projectBuildingRequest.getRepositorySession()
);
+            new DefaultDependencyResolutionRequest( project, buildingRequest.getRepositorySession()
);
 
         DependencyResolutionResult result = resolveDependencies( request, reactorProjects
);
 
@@ -171,8 +170,11 @@ public class Maven3DependencyGraphBuilde
 
     private Artifact getDependencyArtifact( Dependency dep )
     {
+        Artifact mavenArtifact = RepositoryUtils.toArtifact( dep.getArtifact() );
         
-        return RepositoryUtils.toArtifact( dep.getArtifact() );
+        mavenArtifact.setScope( dep.getScope() );
+        
+        return mavenArtifact; 
     }
 
     private DependencyNode buildDependencyNode( DependencyNode parent, org.sonatype.aether.graph.DependencyNode
node,



Mime
View raw message