maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r683731 - in /maven/sandbox/trunk/mercury: ./ mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/ mercury-it/ mercury-it/src/ mercury-it/src/test/ mercury-it/src/test/java/ mercury-it/src/test/resources/ mercury-md/mercury-md-...
Date Thu, 07 Aug 2008 21:44:57 GMT
Author: ogusakov
Date: Thu Aug  7 14:44:56 2008
New Revision: 683731

URL: http://svn.apache.org/viewvc?rev=683731&view=rev
Log:
added list processors for adjusting dependency building behavior, added IT project to start
joint tests

Added:
    maven/sandbox/trunk/mercury/mercury-it/   (with props)
    maven/sandbox/trunk/mercury/mercury-it/pom.xml
    maven/sandbox/trunk/mercury/mercury-it/src/
    maven/sandbox/trunk/mercury/mercury-it/src/test/
    maven/sandbox/trunk/mercury/mercury-it/src/test/java/
    maven/sandbox/trunk/mercury/mercury-it/src/test/resources/
Modified:
    maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/DefaultArtifact.java
    maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/pom.xml
    maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
    maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/VirtualRepositoryReader.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
    maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
    maven/sandbox/trunk/mercury/pom.xml

Modified: maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/DefaultArtifact.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/DefaultArtifact.java?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/DefaultArtifact.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-artifact/src/main/java/org/apache/maven/mercury/artifact/DefaultArtifact.java
Thu Aug  7 14:44:56 2008
@@ -43,6 +43,18 @@
 
         initialize( groupId, artifactId, version, type, classifier, optional, scope, inheritedScope
);
     }
+    
+    public DefaultArtifact( ArtifactBasicMetadata bmd )
+    {
+        if ( bmd.getVersion() == null )
+        {
+            throw new IllegalArgumentException( "Version cannot be null." );
+        }
+
+        initialize( bmd.getGroupId(), bmd.getArtifactId(), bmd.getVersion(), bmd.getType()
+                  , bmd.getClassifier(), bmd.isOptional(), bmd.getScope(), bmd.getScope()

+                  );
+    }
 
     public String getInheritedScope()
     {

Propchange: maven/sandbox/trunk/mercury/mercury-it/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Aug  7 14:44:56 2008
@@ -0,0 +1,4 @@
+.settings
+.project
+target
+.classpath

Added: maven/sandbox/trunk/mercury/mercury-it/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-it/pom.xml?rev=683731&view=auto
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-it/pom.xml (added)
+++ maven/sandbox/trunk/mercury/mercury-it/pom.xml Thu Aug  7 14:44:56 2008
@@ -0,0 +1,12 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.mercury</groupId>
+    <artifactId>mercury-pom</artifactId>
+    <version>1-SNAPSHOT</version>
+  </parent>
+  <artifactId>mercury-it</artifactId>
+  <name>Mercury Integration Tests</name>
+  <description>Mercury Integration Tests</description>
+
+</project>
\ No newline at end of file

Modified: maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/pom.xml?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/pom.xml (original)
+++ maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/pom.xml Thu Aug  7 14:44:56 2008
@@ -10,6 +10,25 @@
   	<artifactId>mercury-md</artifactId>
   	<version>1.0.0-SNAPSHOT</version>
   </parent>
+  <build>
+
+  <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>package-tests</id>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>      
+    </plugins>
+ 
+  </build>
+
   <dependencies>
     <!-- SAT solver used to calculate viable ranges when dependencies are expressed pseudo
boolean form -->
     <dependency>

Modified: maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/main/java/org/apache/maven/mercury/metadata/DependencyTreeBuilder.java
Thu Aug  7 14:44:56 2008
@@ -2,11 +2,13 @@
 
 import java.util.ArrayList;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.artifact.ArtifactListProcessor;
 import org.apache.maven.mercury.artifact.ArtifactMetadata;
 import org.apache.maven.mercury.artifact.ArtifactScopeEnum;
 import org.apache.maven.mercury.builder.api.MetadataProcessor;
@@ -29,6 +31,7 @@
   
   private Set<MetadataTreeArtifactFilter> _filters;
   private List<Comparator<MetadataTreeNode>> _comparators;
+  private Map<String,ArtifactListProcessor> _processors;
   
   private VirtualRepositoryReader _reader;
   
@@ -51,6 +54,7 @@
   public DependencyTreeBuilder(
         Set<MetadataTreeArtifactFilter> filters
       , List<Comparator<MetadataTreeNode>> comparators
+      , Map<String,ArtifactListProcessor> processors
       , List<Repository> repositories
       , MetadataProcessor processor
                      )
@@ -68,9 +72,21 @@
       _comparators.add( new ClassicVersionComparator() );
     }
     
+    if( processors != null )
+      _processors = processors;
+    
     this._reader = new VirtualRepositoryReader( repositories, processor );
   }
-  //-----------------------------------------------------
+  //------------------------------------------------------------------------
+  /**
+   * build the tree, using the repositories specified in the
+   * constructor
+   * 
+   * @param startMD - root of the tree to build
+   * @param targetPlatform - limitations to use when retrieving metadata. Format is G:A=V,
where V is Version Range
+   * @return the root of the tree built
+   * @throws MetadataTreeException
+   */
   public MetadataTreeNode buildTree( ArtifactMetadata startMD )
   throws MetadataTreeException
   {
@@ -79,6 +95,7 @@
     
     try
     {
+      _reader.setProcessors( _processors );
       _reader.init();
     }
     catch( RepositoryException e )

Modified: maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-md/mercury-md-sat/src/test/java/org/apache/maven/mercury/metadata/DependencyTreeBuilderTest.java
Thu Aug  7 14:44:56 2008
@@ -2,6 +2,7 @@
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -33,6 +34,7 @@
   LocalRepositoryM2 localRepo;
   List<Repository> reps;
   MetadataProcessor processor;
+  
   //----------------------------------------------------------------------------------------------
   @Override
   protected void setUp()
@@ -45,7 +47,7 @@
     reps = new ArrayList<Repository>(4);
     reps.add(  localRepo );
 
-    mt = new DependencyTreeBuilder( null, null, reps, processor );
+    mt = new DependencyTreeBuilder( null, null, null, reps, processor );
   }
   //----------------------------------------------------------------------------------------------
   @Override

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/VirtualRepositoryReader.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/VirtualRepositoryReader.java?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/VirtualRepositoryReader.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-api/src/main/java/org/apache/maven/mercury/repository/api/VirtualRepositoryReader.java
Thu Aug  7 14:44:56 2008
@@ -6,6 +6,8 @@
 import java.util.Map;
 
 import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.artifact.ArtifactListProcessor;
+import org.apache.maven.mercury.artifact.ArtifactListProcessorException;
 import org.apache.maven.mercury.artifact.ArtifactMetadata;
 import org.apache.maven.mercury.builder.api.MetadataProcessingException;
 import org.apache.maven.mercury.builder.api.MetadataProcessor;
@@ -14,6 +16,8 @@
 /**
  * this helper class hides the necessity to talk to localRepo and a bunch of remoteRepos.
  * It also adds discrete convenience methods, hiding batch nature of RepositoryReader
+ * 
+ * Please don't forget to initialize target platform if you really need one
  *
  *
  * @author Oleg Gusakov
@@ -25,11 +29,14 @@
 {
   //----------------------------------------------------------------------------------------------------------------------------
   private List<Repository>       _repositories = new ArrayList<Repository>(8);
+
   private RepositoryReader[]     _repositoryReaders;
 
   private LocalRepository       _localRepository;
   
   private MetadataProcessor     _processor;
+
+  private Map<String,ArtifactListProcessor>   _processors;
   
   private boolean _initialized = false;
   //----------------------------------------------------------------------------------------------------------------------------
@@ -83,6 +90,11 @@
     _repositories.add( repo );
   }
   //----------------------------------------------------------------------------------------------------------------------------
+  public void setProcessors( Map<String, ArtifactListProcessor> processors )
+  {
+    _processors = processors; 
+  }
+  //----------------------------------------------------------------------------------------------------------------------------
   public void init()
   throws RepositoryException
   {
@@ -123,6 +135,7 @@
     init();
         
     Map<ArtifactBasicMetadata, List<ArtifactBasicMetadata>> res = null;
+    ArtifactListProcessor tp = _processors == null ? null : _processors.get( ArtifactListProcessor.FUNCTION_TP
);
 
     for( RepositoryReader rr : _repositoryReaders )
     {
@@ -135,6 +148,23 @@
           if( ror != null && !ror.hasExceptions() && ror.hasResults() )
           {
             List<ArtifactBasicMetadata> rorRes = ror.getResults();
+            
+            if( tp != null )
+            {
+              try
+              {
+                tp.configure( key );
+                rorRes = tp.process( rorRes );
+              }
+              catch( ArtifactListProcessorException e )
+              {
+                throw new RepositoryException(e);
+              }
+            }
+            
+            if( rorRes == null )
+              continue;
+            
             for( ArtifactBasicMetadata bmd : rorRes )
               bmd.setTracker(  rr );
             

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryReaderM2.java
Thu Aug  7 14:44:56 2008
@@ -73,10 +73,18 @@
     
     for( ArtifactBasicMetadata bmd : query )
     {
-      if( bmd.getEffectiveGroupId() == null )
-      { // this metadata has not been processed by MetadataProcessor
-        
+      DefaultArtifact da = bmd instanceof DefaultArtifact ? (DefaultArtifact)bmd : new DefaultArtifact(
bmd );
+
+      File binary = new File( _repoDir, pathOf( bmd, null, null) );
+      if( ! binary.exists() )
+      {
+        res.add( new RepositoryException( _lang.getMessage( "binary.not.found", binary.getAbsolutePath()
) ) );
+        continue;
       }
+
+      da.setFile( binary );
+
+      res.add( da );
     }
     return null;
   }
@@ -191,11 +199,16 @@
   public byte[] readRawData( ArtifactBasicMetadata bmd, String classifier, String type )
   throws MetadataProcessingException
   {
+    return readRawData( pathOf(bmd, classifier, type) );
+  }
+  //---------------------------------------------------------------------------------------------------------------
+  private String pathOf( ArtifactBasicMetadata bmd, String classifier, String type )
+  {
     String bmdPath = bmd.getGroupId().replace( '.', '/' )+"/"+bmd.getArtifactId()+"/"+bmd.getVersion();
     
     String path = bmdPath+"/"+bmd.getBaseName(classifier)+'.' + (type == null ? bmd.getType()
: type );
     
-    return readRawData( path );
+    return path ;
   }
   //---------------------------------------------------------------------------------------------------------------
   public byte[] readRawData( String path )

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/LocalRepositoryWriterM2.java
Thu Aug  7 14:44:56 2008
@@ -58,8 +58,7 @@
   /* (non-Javadoc)
    * @see org.apache.maven.mercury.repository.api.RepositoryWriter#writeArtifact(java.util.Collection)
    */
-  public void writeArtifact(
-      Collection<Artifact> artifact )
+  public void writeArtifact( Collection<Artifact> artifact )
       throws RepositoryException
   {
     // TODO Auto-generated method stub

Modified: maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
(original)
+++ maven/sandbox/trunk/mercury/mercury-repo/mercury-repo-local-m2/src/main/java/org/apache/maven/mercury/repository/local/m2/Messages.properties
Thu Aug  7 14:44:56 2008
@@ -1,2 +1,3 @@
 bad.repository.type=repository should implement LocalRepository, instead got {0}
-empty.query=received empty query - {0}
\ No newline at end of file
+empty.query=received empty query - {0}
+binary.not.found=Artifacts's binary {0} not found in the repository 
\ No newline at end of file

Modified: maven/sandbox/trunk/mercury/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mercury/pom.xml?rev=683731&r1=683730&r2=683731&view=diff
==============================================================================
--- maven/sandbox/trunk/mercury/pom.xml (original)
+++ maven/sandbox/trunk/mercury/pom.xml Thu Aug  7 14:44:56 2008
@@ -14,6 +14,7 @@
     <module>mercury-repo</module>
     <module>mercury-transport</module>
     <module>mercury-external</module>
+    <module>mercury-it</module>
   </modules>
 
   <build>



Mime
View raw message