maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r677499 - in /maven/sandbox/trunk/mercury/src: main/java/org/apache/maven/mercury/ main/java/org/apache/maven/mercury/metadata/ main/java/org/apache/maven/mercury/metadata/sat/ test/java/org/apache/maven/mercury/metadata/ test/java/org/apac...
Date Thu, 17 Jul 2008 04:42:27 GMT
Author: ogusakov
Date: Wed Jul 16 21:42:26 2008
New Revision: 677499

URL: http://svn.apache.org/viewvc?rev=677499&view=rev
Log:
scoped resolution implemented. 

Added:
    maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/4/
    maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/4/a-4.pom
Modified:
    maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/ArtifactScopeEnum.java
    maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/MetadataTree.java
    maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolver.java
    maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/MetadataTreeTest.java
    maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolverTest.java
    maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/3/a-3.pom
    maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/c/c/3/c-3.pom

Modified: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/ArtifactScopeEnum.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/ArtifactScopeEnum.java?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/ArtifactScopeEnum.java
(original)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/ArtifactScopeEnum.java
Wed Jul 16 21:42:26 2008
@@ -70,7 +70,7 @@
     
     private static final ArtifactScopeEnum [][][] _compliancySets = {
     	  { { compile  }, { compile,                provided, system } }
-      	, { { test     }, { compile, test,          provided, system } }
+    	, { { test     }, { compile, test,          provided, system } }
     	, { { runtime  }, { compile,       runtime,           system } }
     	, { { provided }, { compile, test,          provided         } }
     };

Modified: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/MetadataTree.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/MetadataTree.java?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/MetadataTree.java
(original)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/MetadataTree.java
Wed Jul 16 21:42:26 2008
@@ -168,7 +168,7 @@
     
     try
     {
-      DefaultSatSolver solver = new DefaultSatSolver( _root );
+      DefaultSatSolver solver = new DefaultSatSolver( _root, scope );
       
       if( _comparators == null )
         _comparators = new ArrayList<Comparator<MetadataTreeNode>>(2);

Modified: maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolver.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolver.java?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolver.java
(original)
+++ maven/sandbox/trunk/mercury/src/main/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolver.java
Wed Jul 16 21:42:26 2008
@@ -9,6 +9,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.maven.mercury.ArtifactScopeEnum;
 import org.apache.maven.mercury.metadata.ArtifactMetadata;
 import org.apache.maven.mercury.metadata.MetadataTreeNode;
 import org.sat4j.core.Vec;
@@ -35,15 +36,16 @@
   protected SatContext _context;
   protected IPBSolver _solver = SolverFactory.newEclipseP2();
   protected MetadataTreeNode _root;
+  protected ArtifactScopeEnum _scope;
   protected static final Comparator<MetadataTreeNode> gaComparator = new MetadataTreeNodeGAComparator();
   //-----------------------------------------------------------------------
-  public static SatSolver create( MetadataTreeNode tree )
+  public static SatSolver create( MetadataTreeNode tree, ArtifactScopeEnum scope )
   throws SatException
   {
-    return new DefaultSatSolver( tree );
+    return new DefaultSatSolver( tree, scope );
   }
   //-----------------------------------------------------------------------
-  public DefaultSatSolver( MetadataTreeNode tree )
+  public DefaultSatSolver( MetadataTreeNode tree, ArtifactScopeEnum scope )
   throws SatException
   {
     if( tree == null)
@@ -53,6 +55,7 @@
     _context = new SatContext( nNodes );
     _solver.newVar( _context.varCount );
     _root = tree;
+    _scope = scope == null ? ArtifactScopeEnum.DEFAULT_SCOPE : scope;
     
     try
     {
@@ -125,7 +128,7 @@
         lastComparator = comparator;
       }
       // due to the nature of Comparator need to reverse the result
-      // as the bets fit is now last
+      // as the best fit is now last
       Collections.reverse( bucket );
 
       // we don't need duplicate GAVs
@@ -156,7 +159,7 @@
   }
   //-----------------------------------------------------------------------
   /**
-   * reorders the bucket's lastComparator "equals" with comparator, most desirable - positive
- elements first.
+   * reorders the bucket's lastComparator equal subsets with comparator.
    */
   protected static final void sortBucket(
                List<MetadataTreeNode> bucket
@@ -348,6 +351,9 @@
     for( Map.Entry<ArtifactMetadata,List<MetadataTreeNode>> kid : kids.entrySet()
)
     {
       ArtifactMetadata query = kid.getKey();
+      if( ! _scope.encloses( query.getArtifactScope()) )
+        continue;
+      
       List<MetadataTreeNode> range = kid.getValue();
 
       if( range.size() > 1 )

Modified: maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/MetadataTreeTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/MetadataTreeTest.java?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/MetadataTreeTest.java
(original)
+++ maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/MetadataTreeTest.java
Wed Jul 16 21:42:26 2008
@@ -100,6 +100,26 @@
     System.out.println( "testResolveConflicts: " + res );
   }
   //----------------------------------------------------------------------------------------------
+  public void testResolveScopedConflicts()
+  throws MetadataTreeException
+  {
+    ArtifactMetadata md = new ArtifactMetadata( "a:a:4" );
+    
+    MetadataTreeNode root = mt.buildTree( md );
+    assertNotNull( "null tree built", root );
+    assertEquals( "wrong tree size", 4, root.countNodes() );
+
+    List<ArtifactMetadata> res = mt.resolveConflicts( ArtifactScopeEnum.compile );
+    assertNotNull( "null resolution", res );
+    assertEquals( "wrong tree size", 2, res.size() );
+
+    System.out.println( "testResolveScopedConflicts: " + res );
+    
+    assertTrue( "no a:a:4 in the result", assertHasArtifact( res, "a:a:4" ) );
+    assertTrue( "no c:c:3 in the result", assertHasArtifact( res, "c:c:3" ) );
+    
+  }
+  //----------------------------------------------------------------------------------------------
   public void testBigResolveConflicts()
   throws MetadataTreeException
   {

Modified: maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolverTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolverTest.java?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolverTest.java
(original)
+++ maven/sandbox/trunk/mercury/src/test/java/org/apache/maven/mercury/metadata/sat/DefaultSatSolverTest.java
Wed Jul 16 21:42:26 2008
@@ -93,7 +93,7 @@
     cc1bb2 = new MetadataTreeNode( mdbb2, cc1, mdbb2 );
     cc1.addChild( cc1bb2 );
     
-    ss = (DefaultSatSolver) DefaultSatSolver.create( aa1 );
+    ss = (DefaultSatSolver) DefaultSatSolver.create( aa1, ArtifactScopeEnum.compile );
     
     List< Comparator<MetadataTreeNode>> comparators = new ArrayList<Comparator<MetadataTreeNode>>(2);
     comparators.add( new ClassicDepthComparator() );
@@ -168,7 +168,7 @@
       .addChild(nb3)
     ;
 
-    ss = (DefaultSatSolver) DefaultSatSolver.create(na1);
+    ss = (DefaultSatSolver) DefaultSatSolver.create(na1, ArtifactScopeEnum.compile);
 
     List<ArtifactMetadata> res = ss.solve();
     

Modified: maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/3/a-3.pom
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/3/a-3.pom?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/3/a-3.pom (original)
+++ maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/3/a-3.pom Wed Jul 16
21:42:26 2008
@@ -1,8 +1,8 @@
 <project>
-	<modelVersion>3</modelVersion>
+	<modelVersion>4.0.0</modelVersion>
   <groupId>a</groupId>
   <artifactId>a</artifactId>
-  <version>1</version>
+  <version>3</version>
 
   <dependencies>
     <dependency>

Added: maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/4/a-4.pom
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/4/a-4.pom?rev=677499&view=auto
==============================================================================
--- maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/4/a-4.pom (added)
+++ maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/a/a/4/a-4.pom Wed Jul 16
21:42:26 2008
@@ -0,0 +1,21 @@
+<project>
+	<modelVersion>3</modelVersion>
+  <groupId>a</groupId>
+  <artifactId>a</artifactId>
+  <version>4</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>b</groupId>
+      <artifactId>b</artifactId>
+      <version>2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>c</groupId>
+      <artifactId>c</artifactId>
+      <version>[2,3]</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Modified: maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/c/c/3/c-3.pom
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/c/c/3/c-3.pom?rev=677499&r1=677498&r2=677499&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/c/c/3/c-3.pom (original)
+++ maven/sandbox/trunk/mercury/src/test/resources/controlledRepo/c/c/3/c-3.pom Wed Jul 16
21:42:26 2008
@@ -1,5 +1,5 @@
 <project>
-  <modelVersion>4</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
   <groupId>c</groupId>
   <artifactId>c</artifactId>
   <version>3</version>



Mime
View raw message