You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/06/08 07:21:15 UTC

svn commit: r412664 - in /maven/repository-manager/trunk/maven-repository-reports-standard/src: main/java/org/apache/maven/repository/reporting/ test/java/org/apache/maven/repository/reporting/

Author: brett
Date: Wed Jun  7 22:21:14 2006
New Revision: 412664

URL: http://svn.apache.org/viewvc?rev=412664&view=rev
Log:
[MRM-118] update recently added duplicate processor

Modified:
    maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java
    maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java

Modified: maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java?rev=412664&r1=412663&r2=412664&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java (original)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java Wed Jun  7 22:21:14 2006
@@ -17,12 +17,9 @@
  */
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.Model;
-import org.apache.maven.repository.digest.DefaultDigester;
 import org.apache.maven.repository.digest.Digester;
-import org.apache.maven.repository.indexing.DefaultRepositoryIndexingFactory;
 import org.apache.maven.repository.indexing.RepositoryIndex;
 import org.apache.maven.repository.indexing.RepositoryIndexException;
 import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
@@ -42,22 +39,29 @@
  * Validates an artifact file for duplicates within the same groupId based from what's available in a RepositoryIndex
  *
  * @author Edwin Punzalan
+ * @plexus.component role="org.apache.maven.repository.reporting.ArtifactReportProcessor" role-hint="duplicate"
  */
 public class DuplicateArtifactFileReportProcessor
     implements ArtifactReportProcessor
 {
+    /**
+     * @plexus.requirement
+     */
     private Digester digester;
 
+    /**
+     * @plexus.requirement
+     */
     private RepositoryIndexingFactory indexFactory;
 
     //@todo configurable?
     private String algorithm = RepositoryIndex.FLD_MD5;
 
+    /**
+     * @plexus.requirement
+     */
     private RepositoryIndexSearchLayer searchLayer;
 
-    //@todo must be injected
-    private ArtifactFactory artifactFactory;
-
     public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
                                  ArtifactRepository repository )
         throws ReportProcessorException
@@ -67,18 +71,6 @@
             //@todo remove hard-coded value; current value enables tests to pass
             String indexPath = new File( "target/.index" ).getAbsolutePath();
 
-            //@todo may be injected?
-            if ( digester == null )
-            {
-                digester = new DefaultDigester();
-            }
-
-            //@todo may be injected?
-            if ( indexFactory == null )
-            {
-                indexFactory = new DefaultRepositoryIndexingFactory();
-            }
-
             RepositoryIndex index;
             try
             {
@@ -89,11 +81,6 @@
                 throw new ReportProcessorException( "Unable to create RepositoryIndex instance", e );
             }
 
-            if ( searchLayer == null )
-            {
-                searchLayer = new RepositoryIndexSearchLayer( index, artifactFactory );
-            }
-
             String checksum;
             try
             {
@@ -112,7 +99,7 @@
 
             try
             {
-                List results = searchLayer.searchAdvanced( query );
+                List results = searchLayer.searchAdvanced( query, index );
 
                 if ( results.isEmpty() )
                 {
@@ -156,15 +143,5 @@
         {
             reporter.addWarning( artifact, "Artifact file is null" );
         }
-    }
-
-    public ArtifactFactory getArtifactFactory()
-    {
-        return artifactFactory;
-    }
-
-    public void setArtifactFactory( ArtifactFactory artifactFactory )
-    {
-        this.artifactFactory = artifactFactory;
     }
 }

Modified: maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java
URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java?rev=412664&r1=412663&r2=412664&view=diff
==============================================================================
--- maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java (original)
+++ maven/repository-manager/trunk/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java Wed Jun  7 22:21:14 2006
@@ -1,9 +1,25 @@
 package org.apache.maven.repository.reporting;
 
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.model.Model;
-import org.apache.maven.repository.digest.DefaultDigester;
+import org.apache.maven.repository.digest.Digester;
 import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
 import org.codehaus.plexus.util.FileUtils;
 
@@ -21,7 +37,7 @@
 
     private Model model;
 
-    private DuplicateArtifactFileReportProcessor processor;
+    private ArtifactReportProcessor processor;
 
     private ArtifactFactory artifactFactory;
 
@@ -31,14 +47,15 @@
         throws Exception
     {
         super.setUp();
-        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.class.getName() );
+        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+        Digester digester = (Digester) lookup( Digester.ROLE );
+
         reporter = new MockArtifactReporter();
         artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "jar" );
         model = new Model();
-        processor = new DuplicateArtifactFileReportProcessor();
-        processor.setArtifactFactory( artifactFactory );
+        processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
 
-        ArtifactRepositoryIndex index = new ArtifactRepositoryIndex( indexPath, repository, new DefaultDigester() );
+        ArtifactRepositoryIndex index = new ArtifactRepositoryIndex( indexPath, repository, digester );
         index.indexArtifact( artifact );
         index.optimize();
         index.close();