From: Brett Porter Date: Sat, 26 Aug 2006 11:25:57 +0000 (+0000) Subject: [MRM-145] index skins X-Git-Tag: archiva-0.9-alpha-1~645 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=87fef8ad23f6c4932e2c9a819a3d8121b9e7325e;p=archiva.git [MRM-145] index skins git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@437144 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactory.java b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactory.java index d97a1d6cf..d4f67b3e4 100644 --- a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactory.java +++ b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactory.java @@ -81,6 +81,10 @@ public class StandardArtifactIndexRecordFactory */ protected Digester md5Digester; + private static final String SITE_TEMPLATE_NAME = "META-INF/maven/site.vm"; + + private static final String SITE_CSS_NAME = "css/maven-theme.css"; + private static final String PLUGIN_METADATA_NAME = "META-INF/maven/plugin.xml"; private static final String ARCHETYPE_METADATA_NAME = "META-INF/maven/archetype.xml"; @@ -236,6 +240,10 @@ public class StandardArtifactIndexRecordFactory { populateArchetypeEntries( record ); } + else if ( SITE_TEMPLATE_NAME.equals( name ) || SITE_CSS_NAME.equals( name ) ) + { + populateSkinEntries( record ); + } } } @@ -255,6 +263,12 @@ public class StandardArtifactIndexRecordFactory record.setType( "maven-archetype" ); } + private void populateSkinEntries( StandardArtifactIndexRecord record ) + { + // Typically discovered as a JAR + record.setType( "maven-skin" ); + } + private Xpp3Dom readXmlMetadataFileInJar( File file, String name ) throws RepositoryIndexException { diff --git a/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/MinimalArtifactIndexRecordFactoryTest.java b/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/MinimalArtifactIndexRecordFactoryTest.java index a2aeba0b3..f40700f11 100644 --- a/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/MinimalArtifactIndexRecordFactoryTest.java +++ b/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/MinimalArtifactIndexRecordFactoryTest.java @@ -168,6 +168,12 @@ public class MinimalArtifactIndexRecordFactoryTest record = factory.createRecord( artifact ); assertNull( "Check no record", record ); + + artifact = createArtifact( "test-skin", "1.0", "pom" ); + + record = factory.createRecord( artifact ); + + assertNull( "Check no record", record ); } public void testIndexedPlugin() diff --git a/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactoryTest.java b/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactoryTest.java index 42ea5756a..3a425ca61 100644 --- a/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactoryTest.java +++ b/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecordFactoryTest.java @@ -254,6 +254,12 @@ public class StandardArtifactIndexRecordFactoryTest record = factory.createRecord( artifact ); assertNull( "Check no record", record ); + + artifact = createArtifact( "test-skin", "1.0", "pom" ); + + record = factory.createRecord( artifact ); + + assertNull( "Check no record", record ); } public void testIndexedPlugin() @@ -316,6 +322,34 @@ public class StandardArtifactIndexRecordFactoryTest assertEquals( "check record", expectedRecord, record ); } + public void testIndexedSkin() + throws RepositoryIndexException, IOException, XmlPullParserException + { + Artifact artifact = createArtifact( "test-skin" ); + + RepositoryIndexRecord record = factory.createRecord( artifact ); + + StandardArtifactIndexRecord expectedRecord = new StandardArtifactIndexRecord(); + expectedRecord.setMd5Checksum( "ba2d8a722f763db2950ad63119585f45" ); + expectedRecord.setFilename( repository.pathOf( artifact ) ); + expectedRecord.setLastModified( artifact.getFile().lastModified() ); + expectedRecord.setSize( artifact.getFile().length() ); + expectedRecord.setArtifactId( "test-skin" ); + expectedRecord.setGroupId( TEST_GROUP_ID ); + expectedRecord.setBaseVersion( "1.0" ); + expectedRecord.setVersion( "1.0" ); + expectedRecord.setSha1Checksum( "44855e3e56c18ce766db315a2d4c114d7a8c8ab0" ); + expectedRecord.setType( "maven-skin" ); + expectedRecord.setRepository( "test" ); + expectedRecord.setFiles( Arrays.asList( new String[]{"META-INF/MANIFEST.MF", "css/maven-theme.css", + "META-INF/maven/org.apache.maven.skins/test-skin/pom.xml", + "META-INF/maven/org.apache.maven.skins/test-skin/pom.properties"} ) ); + expectedRecord.setPackaging( "jar" ); + expectedRecord.setProjectName( "Skin - test-skin" ); + + assertEquals( "check record", expectedRecord, record ); + } + public void testCorruptJar() throws RepositoryIndexException { diff --git a/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar new file mode 100644 index 000000000..99bd1e78b Binary files /dev/null and b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.jar differ diff --git a/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.pom b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.pom new file mode 100644 index 000000000..2055446f6 --- /dev/null +++ b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-skin/1.0/test-skin-1.0.pom @@ -0,0 +1,8 @@ + + 4.0.0 + org.apache.maven.archiva.record + test-skin + 1.0 + Skin - test-skin +