maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r576964 - in /maven/shared/trunk/maven-dependency-tree/src: main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java test/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.java
Date Tue, 18 Sep 2007 16:08:24 GMT
Author: markh
Date: Tue Sep 18 09:08:23 2007
New Revision: 576964

URL: http://svn.apache.org/viewvc?rev=576964&view=rev
Log:
Fixed dependency management information for nodes that are also omitted for conflicts.

Modified:
    maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
    maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.java

Modified: maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java?rev=576964&r1=576963&r2=576964&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/main/java/org/apache/maven/shared/dependency/tree/DependencyTreeResolutionListener.java
Tue Sep 18 09:08:23 2007
@@ -166,23 +166,7 @@
              * Add the dependency management information cached in any prior manageArtifact
calls, since includeArtifact
              * is always called after manageArtifact.
              */
-            String premanagedVersion = (String) managedVersions.get( artifact.getId() );
-            String premanagedScope = (String) managedScopes.get( artifact.getId() );
-            if ( premanagedVersion != null || premanagedScope != null )
-            {
-                if ( premanagedVersion != null )
-                {
-                    node.setPremanagedVersion( premanagedVersion );
-                }
-                
-                if ( premanagedScope != null )
-                {
-                    node.setPremanagedScope( premanagedScope );
-                }
-                
-                premanagedVersion = null;
-                premanagedScope = null;
-            }
+            flushDependencyManagement( node );
         }
     }
 
@@ -218,7 +202,11 @@
 
             omittedNode.omitForConflict( kept );
             
-            
+            /*
+             * Add the dependency management information cached in any prior manageArtifact
calls, since omitForNearer
+             * is always called after manageArtifact.
+             */
+            flushDependencyManagement( omittedNode );
             
             DependencyNode keptNode = getNode( kept );
             
@@ -520,5 +508,35 @@
         }
 
         return included;
+    }
+
+    /**
+     * Updates the specified node with any dependency management information cached in prior
<code>manageArtifact</code>
+     * calls.
+     * 
+     * @param node
+     *            the node to update
+     */
+    private void flushDependencyManagement( DependencyNode node )
+    {
+        Artifact artifact = node.getArtifact();
+        String premanagedVersion = (String) managedVersions.get( artifact.getId() );
+        String premanagedScope = (String) managedScopes.get( artifact.getId() );
+        
+        if ( premanagedVersion != null || premanagedScope != null )
+        {
+            if ( premanagedVersion != null )
+            {
+                node.setPremanagedVersion( premanagedVersion );
+            }
+            
+            if ( premanagedScope != null )
+            {
+                node.setPremanagedScope( premanagedScope );
+            }
+            
+            premanagedVersion = null;
+            premanagedScope = null;
+        }
     }
 }

Modified: maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.java?rev=576964&r1=576963&r2=576964&view=diff
==============================================================================
--- maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.java
(original)
+++ maven/shared/trunk/maven-dependency-tree/src/test/java/org/apache/maven/shared/dependency/tree/DependencyTreeBuilderTest.java
Tue Sep 18 09:08:23 2007
@@ -463,6 +463,44 @@
 
         assertDependencyTree( expectedRootNode, project );
     }
+    
+    /**
+     * Tests building a tree for a project with a dependency that has conflicting versions
and the version is also fixed
+     * in dependency management:
+     * 
+     * <pre>
+     * g:p:t:1
+     * +- g:a:t:1
+     * \- g:b:t:1
+     *    \- (g:a:t:3 - version managed from 2; omitted for conflict with 1)
+     * </pre>
+     * 
+     * @throws DependencyTreeBuilderException
+     * @throws ArtifactResolutionException
+     */
+    public void testProjectWithManagedTransitiveDependencyVersionAndConflictDependencyVersion()
throws DependencyTreeBuilderException, ArtifactResolutionException
+    {
+        Artifact projectArtifact = createArtifact( "g:p:t:1" );
+        Artifact nearestArtifact = createArtifact( "g:a:t:1" );
+        Artifact childArtifact = createArtifact( "g:b:t:1" );
+        Artifact farthestArtifact = createArtifact( "g:a:t:2" );
+        Artifact managedTransitiveArtifact = createArtifact( "g:a:t:3" );
+        addArtifactMetadata( childArtifact, farthestArtifact );
+
+        MavenProject project = createProject( projectArtifact, new Artifact[] { nearestArtifact,
childArtifact } );
+        setManagedVersionMap( project, Collections.singleton( managedTransitiveArtifact )
);
+
+        DependencyNode expectedRootNode = createNode( "g:p:t:1" );
+        DependencyNode nearestArtifactNode = createNode( "g:a:t:1" );
+        expectedRootNode.addChild( nearestArtifactNode );
+        DependencyNode childArtifactNode = createNode( "g:b:t:1" );
+        expectedRootNode.addChild( childArtifactNode );
+        DependencyNode managedTransitiveArtifactNode = createNode( "g:a:t:3", DependencyNode.OMITTED_FOR_CONFLICT,
nearestArtifactNode.getArtifact() );
+        managedTransitiveArtifactNode.setPremanagedVersion( "2" );
+        childArtifactNode.addChild( managedTransitiveArtifactNode );
+
+        assertDependencyTree( expectedRootNode, project );
+    }
 
     // TODO: reinstate when MNG-3089 fixed
     /*



Mime
View raw message