Author: brett
Date: Wed Jul 26 20:59:01 2006
New Revision: 425947

URL: http://svn.apache.org/viewvc?rev=425947&view=rev
Log:
[MNG-127] cull POMs that belong to other artifacts from the list

Modified:
    
maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java
    
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java
    
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java

Modified: 
maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java
URL: 
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java?rev=425947&r1=425946&r2=425947&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java
 Wed Jul 26 20:59:01 2006
@@ -125,7 +125,17 @@
                 }
                 else
                 {
-                    populatePomEntries( readPom( file ), record );
+                    Model model = readPom( file );
+
+                    if ( !"pom".equals( model.getPackaging() ) )
+                    {
+                        // Don't return a record for a POM that is does not 
belong on its own
+                        record = null;
+                    }
+                    else
+                    {
+                        populatePomEntries( model, record );
+                    }
                 }
             }
         }

Modified: 
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java
URL: 
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java?rev=425947&r1=425946&r2=425947&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java
 Wed Jul 26 20:59:01 2006
@@ -107,6 +107,29 @@
         assertNull( "Check no record", record );
     }
 
+    public void testNonIndexedPom()
+        throws RepositoryIndexException
+    {
+        // If we pass in only the POM that belongs to a JAR, then expect null 
not the POM
+        Artifact artifact = createArtifact( "test-jar-and-pom", "1.0", "pom" );
+
+        RepositoryIndexRecord record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
+
+        artifact = createArtifact( "test-plugin", "1.0", "pom" );
+
+        record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
+
+        artifact = createArtifact( "test-archetype", "1.0", "pom" );
+
+        record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
+    }
+
     public void testIndexedPlugin()
         throws RepositoryIndexException, IOException, XmlPullParserException
     {

Modified: 
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java
URL: 
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java?rev=425947&r1=425946&r2=425947&view=diff
==============================================================================
--- 
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java
 (original)
+++ 
maven/repository-manager/trunk/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java
 Wed Jul 26 20:59:01 2006
@@ -139,6 +139,29 @@
         assertEquals( "check record", expectedRecord, record );
     }
 
+    public void testNonIndexedPom()
+        throws RepositoryIndexException
+    {
+        // If we pass in only the POM that belongs to a JAR, then expect null 
not the POM
+        Artifact artifact = createArtifact( "test-jar-and-pom", "1.0", "pom" );
+
+        RepositoryIndexRecord record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
+
+        artifact = createArtifact( "test-plugin", "1.0", "pom" );
+
+        record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
+
+        artifact = createArtifact( "test-archetype", "1.0", "pom" );
+
+        record = factory.createRecord( artifact );
+
+        assertNull( "Check no record", record );
+    }
+
     public void testIndexedPlugin()
         throws RepositoryIndexException, IOException, XmlPullParserException
     {


Reply via email to