From: Brett Porter Date: Thu, 27 Jul 2006 03:59:01 +0000 (+0000) Subject: [MRM-127] cull POMs that belong to other artifacts from the list X-Git-Tag: archiva-0.9-alpha-1~738 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1c20fd9fd85aa7e59032f11d00878164007fded8;p=archiva.git [MRM-127] cull POMs that belong to other artifacts from the list git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@425947 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java index cab0b91fd..e422afb71 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactory.java @@ -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 ); + } } } } diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java index bffd0ca15..6a91d3da7 100644 --- a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/MinimalArtifactIndexRecordFactoryTest.java @@ -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 { diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java index 8c345752b..27219f877 100644 --- a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/record/StandardArtifactIndexRecordFactoryTest.java @@ -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 {