maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r711143 - in /maven/mercury/trunk: mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/ mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/ mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercu...
Date Tue, 04 Nov 2008 00:31:52 GMT
Author: ogusakov
Date: Mon Nov  3 16:31:51 2008
New Revision: 711143

URL: http://svn.apache.org/viewvc?rev=711143&view=rev
Log:
scoping, filtering work

Modified:
    maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilderFactory.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
    maven/mercury/trunk/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
    maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
    maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java

Modified: maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java?rev=711143&r1=711142&r2=711143&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
(original)
+++ maven/mercury/trunk/mercury-it/src/test/java/org/apache/maven/mercury/dependency/tests/DependencyTreeBuilderTest.java
Mon Nov  3 16:31:51 2008
@@ -77,7 +77,7 @@
 //    RemoteRepositoryM2 centralRepo = new RemoteRepositoryM2(central);
 //    reps.add(centralRepo);
 
-    depBuilder = DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL,
null, null, null, reps );
+    depBuilder = DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL,
reps, null, null, null );
     
     vReader = new VirtualRepositoryReader( reps );
   }

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilderFactory.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilderFactory.java?rev=711143&r1=711142&r2=711143&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilderFactory.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyBuilderFactory.java
Mon Nov  3 16:31:51 2008
@@ -28,15 +28,15 @@
   
   public static final DependencyBuilder create(
         final String dependencyModel
+      , final Collection<Repository> repositories
       , final Collection<MetadataTreeArtifactFilter> filters
       , final List<Comparator<MetadataTreeNode>> comparators
       , final Map<String,ArtifactListProcessor> processors
-      , final Collection<Repository> repositories
                      )
   throws RepositoryException
   {
     if( JAVA_DEPENDENCY_MODEL.equals( dependencyModel ) )
-      return new DependencyTreeBuilder( filters,  comparators, processors, repositories );
+      return new DependencyTreeBuilder( repositories,  filters, comparators, processors );
     
     throw new IllegalArgumentException( _lang.getMessage( "dependency.model.not.implemented",
dependencyModel ) );
   }

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java?rev=711143&r1=711142&r2=711143&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
Mon Nov  3 16:31:51 2008
@@ -57,10 +57,10 @@
    * @throws RepositoryException
    */
   protected DependencyTreeBuilder(
-        Collection<MetadataTreeArtifactFilter> filters
+        Collection<Repository> repositories
+      , Collection<MetadataTreeArtifactFilter> filters
       , List<Comparator<MetadataTreeNode>> comparators
       , Map<String,ArtifactListProcessor> processors
-      , Collection<Repository> repositories
                      )
   throws RepositoryException
   {
@@ -239,10 +239,10 @@
     {
       ArtifactBasicMetadata md = n.getQuery();
       
-      if( md.allowDependency( ver ) )
-        return false;
+      if( !md.allowDependency( ver ) ) // veto it
+        return true;
     }
-    return true;
+    return false; // allow because all parents are OK with it
   }
   //-----------------------------------------------------
   public List<ArtifactMetadata> resolveConflicts( MetadataTreeNode root, ArtifactScopeEnum
scope )
@@ -282,7 +282,7 @@
     return _comparators;
   }
   //-----------------------------------------------------
-  public List<ArtifactMetadata> resolveConflicts( List<ArtifactBasicMetadata>trees,
ArtifactScopeEnum scope )
+  private List<ArtifactMetadata> resolveConflicts( List<ArtifactBasicMetadata>trees,
ArtifactScopeEnum scope )
   throws MetadataTreeException
   {
     if( Util.isEmpty( trees ) )

Modified: maven/mercury/trunk/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java?rev=711143&r1=711142&r2=711143&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
(original)
+++ maven/mercury/trunk/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
Mon Nov  3 16:31:51 2008
@@ -42,12 +42,12 @@
   {
     processor = new MetadataProcessorMock();
     localRepo = new LocalRepositoryM2( "local", repoDir );
-    localRepo.setDependencyProcessor( new MetadataProcessorMock() );
+//    localRepo.setDependencyProcessor( new MetadataProcessorMock() );
     
     reps = new ArrayList<Repository>(4);
     reps.add(  localRepo );
 
-    mt = new DependencyTreeBuilder( null, null, null, reps );
+    mt = new DependencyTreeBuilder( reps, null, null, null );
   }
   //----------------------------------------------------------------------------------------------
   @Override

Modified: maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java?rev=711143&r1=711142&r2=711143&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
(original)
+++ maven/mercury/trunk/mercury-plexus/src/main/java/org/apache/maven/mercury/plexus/DefaultPlexusMercury.java
Mon Nov  3 16:31:51 2008
@@ -212,10 +212,10 @@
   //---------------------------------------------------------------
 
   public List<ArtifactMetadata> resolve(
-                                        List<Repository> repos,
-                                        ArtifactScopeEnum scope,
-                                        List<ArtifactBasicMetadata> artifacts
-                                                      )
+                          List<Repository> repos,
+                          ArtifactScopeEnum scope,
+                          List<ArtifactBasicMetadata> artifacts
+                                        )
   throws RepositoryException
   {
     if( Util.isEmpty( artifacts ) )
@@ -226,7 +226,7 @@
     
     try
     {
-      DependencyBuilder depBuilder = DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL,
null, null, null, repos );
+      DependencyBuilder depBuilder = DependencyBuilderFactory.create( DependencyBuilderFactory.JAVA_DEPENDENCY_MODEL,
repos, null, null, null );
       
       MetadataTreeNode root = depBuilder.buildTree( artifacts.get(0) );
       List<ArtifactMetadata> res = depBuilder.resolveConflicts( root, scope );

Modified: maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java?rev=711143&r1=711142&r2=711143&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
(original)
+++ maven/mercury/trunk/mercury-plexus/src/test/java/org/apache/maven/mercury/plexus/DefaultPlexusMercuryTest.java
Mon Nov  3 16:31:51 2008
@@ -122,6 +122,17 @@
     
     super.tearDown();
   }
+  //----------------------------------------------------------------------------------------------
+  private static boolean assertHasArtifact( List<ArtifactBasicMetadata> res, String
gav )
+  {
+    ArtifactMetadata gavMd = new ArtifactMetadata(gav);
+    
+    for( ArtifactBasicMetadata md : res )
+      if( md.sameGAV( gavMd ) )
+        return true;
+    
+    return false;
+  }
   //-------------------------------------------------------------------------------------
   public void notestWrite()
   throws RepositoryException
@@ -180,16 +191,35 @@
     assertTrue( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
     assertTrue( assertHasArtifact( res, "asm:asm:3.0" ) );
   }
-  //----------------------------------------------------------------------------------------------
-  private static boolean assertHasArtifact( List<ArtifactBasicMetadata> res, String
gav )
+  //-------------------------------------------------------------------------------------
+  @SuppressWarnings("unchecked")
+  public void testResolveWithExclusion()
+  throws Exception
   {
-    ArtifactMetadata gavMd = new ArtifactMetadata(gav);
+//    Server central = new Server( "central", new URL("http://repo1.maven.org/maven2") );
+    Server central = new Server( "central", new URL("http://repository.sonatype.org/content/groups/public")
);
     
-    for( ArtifactBasicMetadata md : res )
-      if( md.sameGAV( gavMd ) )
-        return true;
+    repos.add( new RemoteRepositoryM2(central) );
+
+    String artifactId = "asm:asm-xml:3.0";
+
+    ArtifactBasicMetadata bmd = new ArtifactBasicMetadata( artifactId );
     
-    return false;
+    List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>();
+    exclusions.add( new ArtifactBasicMetadata("asm:asm:3.0") );
+    
+    bmd.setExclusions( exclusions );
+    
+    List<ArtifactBasicMetadata> res = (List<ArtifactBasicMetadata>)pm.resolve(
repos, ArtifactScopeEnum.compile, bmd );
+    
+    System.out.println("Resolved as "+res);
+
+    assertEquals( 3, res.size() );
+    
+    assertTrue( assertHasArtifact( res, "asm:asm-xml:3.0" ) );
+    assertTrue( assertHasArtifact( res, "asm:asm-util:3.0" ) );
+    assertTrue( assertHasArtifact( res, "asm:asm-tree:3.0" ) );
+    assertFalse( assertHasArtifact( res, "asm:asm:3.0" ) );
   }
   //-------------------------------------------------------------------------------------
   //-------------------------------------------------------------------------------------



Mime
View raw message