]> source.dussan.org Git - archiva.git/commitdiff
[MRM-127] cull POMs that belong to other artifacts from the list
authorBrett Porter <brett@apache.org>
Thu, 27 Jul 2006 03:59:01 +0000 (03:59 +0000)
committerBrett Porter <brett@apache.org>
Thu, 27 Jul 2006 03:59:01 +0000 (03:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@425947 13f79535-47bb-0310-9956-ffa450edef68

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

index cab0b91fd123a34bfcedab761a9d9d0ea01a9462..e422afb71ae6e2e733026170e56ba71b28e084e6 100644 (file)
@@ -125,7 +125,17 @@ public class StandardArtifactIndexRecordFactory
                 }
                 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 );
+                    }
                 }
             }
         }
index bffd0ca15cd60144d1d8b7d7ca3a135c040baee4..6a91d3da782a0c5faa3ddb909e5665c437d45aa7 100644 (file)
@@ -107,6 +107,29 @@ public class MinimalArtifactIndexRecordFactoryTest
         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
     {
index 8c345752bad743a9b3b9ccfe04b0d270f240e704..27219f87759283302d6b5db931ce9f162db966fc 100644 (file)
@@ -139,6 +139,29 @@ public class StandardArtifactIndexRecordFactoryTest
         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
     {