diff --git a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneStandardIndexRecordConverter.java b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneStandardIndexRecordConverter.java
index f64dd4a85..f97275c98 100644
--- a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneStandardIndexRecordConverter.java
+++ b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneStandardIndexRecordConverter.java
@@ -73,9 +73,18 @@ public class LuceneStandardIndexRecordConverter
addUntokenizedField( document, StandardIndexRecordFields.INCEPTION_YEAR, rec.getInceptionYear() );
addTokenizedField( document, StandardIndexRecordFields.PROJECT_NAME, rec.getProjectName() );
addTokenizedField( document, StandardIndexRecordFields.PROJECT_DESCRIPTION, rec.getProjectDescription() );
+ if ( rec.getDependencies() != null )
+ {
+ addTokenizedField( document, StandardIndexRecordFields.DEPENDENCIES,
+ StringUtils.join( rec.getDependencies().iterator(), "\n" ) );
+ }
+ if ( rec.getDevelopers() != null )
+ {
+ addTokenizedField( document, StandardIndexRecordFields.DEVELOPERS,
+ StringUtils.join( rec.getDevelopers().iterator(), "\n" ) );
+ }
/* TODO: add later
document.add( Field.Keyword( StandardIndexRecordFields.FLD_LICENSE_URLS, "" ) );
- document.add( Field.Keyword( StandardIndexRecordFields.FLD_DEPENDENCIES, "" ) );
document.add( Field.Keyword( StandardIndexRecordFields.FLD_PLUGINS_REPORT, "" ) );
document.add( Field.Keyword( StandardIndexRecordFields.FLD_PLUGINS_BUILD, "" ) );
*/
@@ -111,6 +120,16 @@ public class LuceneStandardIndexRecordConverter
{
record.setFiles( Arrays.asList( files.split( "\n" ) ) );
}
+ String dependencies = document.get( StandardIndexRecordFields.DEPENDENCIES );
+ if ( dependencies != null )
+ {
+ record.setDependencies( Arrays.asList( dependencies.split( "\n" ) ) );
+ }
+ String developers = document.get( StandardIndexRecordFields.DEVELOPERS );
+ if ( developers != null )
+ {
+ record.setDevelopers( Arrays.asList( developers.split( "\n" ) ) );
+ }
record.setPluginPrefix( document.get( StandardIndexRecordFields.PLUGIN_PREFIX ) );
record.setInceptionYear( document.get( StandardIndexRecordFields.INCEPTION_YEAR ) );
record.setProjectName( document.get( StandardIndexRecordFields.PROJECT_NAME ) );
diff --git a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java
index ae60fcfa2..625d43e5f 100644
--- a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java
+++ b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardArtifactIndexRecord.java
@@ -96,6 +96,16 @@ public class StandardArtifactIndexRecord
*/
private String baseVersion;
+ /**
+ * A list of dependencies for the artifact, each a string of the form groupId:artifactId:version
.
+ */
+ private List dependencies;
+
+ /**
+ * A list of developers in the POM, each a string of the form id:name:email
.
+ */
+ private List developers;
+
public void setSha1Checksum( String sha1Checksum )
{
this.sha1Checksum = sha1Checksum;
@@ -164,6 +174,14 @@ public class StandardArtifactIndexRecord
{
return false;
}
+ if ( dependencies != null ? !dependencies.equals( that.dependencies ) : that.dependencies != null )
+ {
+ return false;
+ }
+ if ( developers != null ? !developers.equals( that.developers ) : that.developers != null )
+ {
+ return false;
+ }
if ( files != null ? !files.equals( that.files ) : that.files != null )
{
return false;
@@ -228,6 +246,8 @@ public class StandardArtifactIndexRecord
result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 );
result = 31 * result + ( type != null ? type.hashCode() : 0 );
result = 31 * result + ( files != null ? files.hashCode() : 0 );
+ result = 31 * result + ( developers != null ? developers.hashCode() : 0 );
+ result = 31 * result + ( dependencies != null ? dependencies.hashCode() : 0 );
result = 31 * result + ( repository != null ? repository.hashCode() : 0 );
result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 );
result = 31 * result + ( pluginPrefix != null ? pluginPrefix.hashCode() : 0 );
@@ -336,4 +356,24 @@ public class StandardArtifactIndexRecord
{
return baseVersion;
}
+
+ public void setDependencies( List dependencies )
+ {
+ this.dependencies = dependencies;
+ }
+
+ public void setDevelopers( List developers )
+ {
+ this.developers = developers;
+ }
+
+ public List getDevelopers()
+ {
+ return developers;
+ }
+
+ public List getDependencies()
+ {
+ return dependencies;
+ }
}
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 d4f67b3e4..965adfe1c 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
@@ -21,6 +21,8 @@ import org.apache.maven.archiva.indexer.RepositoryIndexException;
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.Dependency;
+import org.apache.maven.model.Developer;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
@@ -136,6 +138,7 @@ public class StandardArtifactIndexRecordFactory
record.setLastModified( file.lastModified() );
record.setSize( file.length() );
record.setRepository( artifact.getRepository().getId() );
+
if ( files != null )
{
populateArchiveEntries( files, record, artifact.getFile() );
@@ -196,14 +199,53 @@ public class StandardArtifactIndexRecordFactory
record.setProjectDescription( pom.getDescription() );
record.setInceptionYear( pom.getInceptionYear() );
+ List dependencies = populateDependencies( pom.getDependencies() );
+ if ( !dependencies.isEmpty() )
+ {
+ record.setDependencies( dependencies );
+ }
+ List developers = populateDevelopers( pom.getDevelopers() );
+ if ( !developers.isEmpty() )
+ {
+ record.setDevelopers( developers );
+ }
+
/* TODO: fields for later
indexPlugins( doc, FLD_PLUGINS_BUILD, pom.getBuild().getPlugins().iterator() );
indexReportPlugins( doc, FLD_PLUGINS_REPORT, pom.getReporting().getPlugins().iterator() );
- record.setDependencies( dependencies );
record.setLicenses( licenses );
*/
}
+ private List populateDependencies( List dependencies )
+ {
+ List convertedDependencies = new ArrayList();
+
+ for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+ {
+ Dependency dependency = (Dependency) i.next();
+
+ convertedDependencies.add(
+ dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() );
+ }
+
+ return convertedDependencies;
+ }
+
+ private List populateDevelopers( List developers )
+ {
+ List convertedDevelopers = new ArrayList();
+
+ for ( Iterator i = developers.iterator(); i.hasNext(); )
+ {
+ Developer developer = (Developer) i.next();
+
+ convertedDevelopers.add( developer.getId() + ":" + developer.getName() + ":" + developer.getEmail() );
+ }
+
+ return convertedDevelopers;
+ }
+
private Model readPom( Artifact artifact, ArtifactRepository repository )
throws RepositoryIndexException, ProjectBuildingException
{
diff --git a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardIndexRecordFields.java b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardIndexRecordFields.java
index 437bac350..4f63154a5 100644
--- a/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardIndexRecordFields.java
+++ b/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/record/StandardIndexRecordFields.java
@@ -70,6 +70,10 @@ public class StandardIndexRecordFields
public static final String PROJECT_DESCRIPTION = "projectDesc";
+ public static final String DEVELOPERS = "developers";
+
+ public static final String DEPENDENCIES = "dependencies";
+
private StandardIndexRecordFields()
{
// No touchy!
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 3a425ca61..6d3733a1d 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
@@ -28,7 +28,9 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -52,6 +54,10 @@ public class StandardArtifactIndexRecordFactoryTest
private static final List JAR_FILE_LIST =
Arrays.asList( new String[]{"META-INF/MANIFEST.MF", "A.class", "b/B.class", "b/c/C.class"} );
+ private static final String JUNIT_DEPENDENCY = "junit:junit:3.8.1";
+
+ private static final String PLUGIN_API_DEPENDENCY = "org.apache.maven:maven-plugin-api:2.0";
+
protected void setUp()
throws Exception
{
@@ -145,6 +151,8 @@ public class StandardArtifactIndexRecordFactoryTest
expectedRecord.setRepository( "test" );
expectedRecord.setPackaging( "jar" );
expectedRecord.setProjectName( "Test JAR and POM" );
+ expectedRecord.setDependencies( createDependencies() );
+ expectedRecord.setDevelopers( createDevelopers() );
assertEquals( "check record", expectedRecord, record );
}
@@ -173,6 +181,8 @@ public class StandardArtifactIndexRecordFactoryTest
expectedRecord.setPackaging( "jar" );
expectedRecord.setProjectName( "Test JAR and POM" );
expectedRecord.setClassifier( "jdk14" );
+ expectedRecord.setDependencies( createDependencies() );
+ expectedRecord.setDevelopers( createDevelopers() );
assertEquals( "check record", expectedRecord, record );
}
@@ -202,6 +212,7 @@ public class StandardArtifactIndexRecordFactoryTest
expectedRecord.setProjectName( "Child Project" );
expectedRecord.setProjectDescription( "Description" );
expectedRecord.setInceptionYear( "2005" );
+ expectedRecord.setDependencies( Collections.singletonList( JUNIT_DEPENDENCY ) );
assertEquals( "check record", expectedRecord, record );
}
@@ -289,6 +300,7 @@ public class StandardArtifactIndexRecordFactoryTest
expectedRecord.setPackaging( "maven-plugin" );
expectedRecord.setProjectName( "Maven Mojo Archetype" );
expectedRecord.setPluginPrefix( "test" );
+ expectedRecord.setDependencies( Arrays.asList( new String[]{JUNIT_DEPENDENCY, PLUGIN_API_DEPENDENCY} ) );
assertEquals( "check record", expectedRecord, record );
}
@@ -413,4 +425,19 @@ public class StandardArtifactIndexRecordFactoryTest
artifact.setRepository( repository );
return artifact;
}
+
+ private static List createDevelopers()
+ {
+ List developers = new ArrayList();
+ developers.add( "brett:Brett Porter:brett@apache.org" );
+ return developers;
+ }
+
+ private static List createDependencies()
+ {
+ List dependencies = new ArrayList();
+ dependencies.add( JUNIT_DEPENDENCY );
+ dependencies.add( "org.apache.maven:maven-project:2.0" );
+ return dependencies;
+ }
}
diff --git a/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-jar-and-pom/1.0-alpha-1/test-jar-and-pom-1.0-alpha-1.pom b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-jar-and-pom/1.0-alpha-1/test-jar-and-pom-1.0-alpha-1.pom
index dce711522..cc8085fb1 100644
--- a/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-jar-and-pom/1.0-alpha-1/test-jar-and-pom-1.0-alpha-1.pom
+++ b/archiva-indexer/src/test/managed-repository/org/apache/maven/archiva/record/test-jar-and-pom/1.0-alpha-1/test-jar-and-pom-1.0-alpha-1.pom
@@ -22,6 +22,11 @@
1.0-alpha-1
Test JAR and POM
+
+ org.apache.maven
+ maven-project
+ 2.0
+
junit
junit
@@ -29,4 +34,14 @@
test
+
+
+ brett
+ Brett Porter
+ brett@apache.org
+
+ Developer
+
+
+