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, "" ) );
*/
{
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 ) );
*/
private String baseVersion;
+ /**
+ * A list of dependencies for the artifact, each a string of the form <code>groupId:artifactId:version</code>.
+ */
+ private List dependencies;
+
+ /**
+ * A list of developers in the POM, each a string of the form <code>id:name:email</code>.
+ */
+ private List developers;
+
public void setSha1Checksum( String sha1Checksum )
{
this.sha1Checksum = sha1Checksum;
{
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;
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 );
{
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;
+ }
}
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;
record.setLastModified( file.lastModified() );
record.setSize( file.length() );
record.setRepository( artifact.getRepository().getId() );
+
if ( files != null )
{
populateArchiveEntries( files, record, artifact.getFile() );
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
{
public static final String PROJECT_DESCRIPTION = "projectDesc";
+ public static final String DEVELOPERS = "developers";
+
+ public static final String DEPENDENCIES = "dependencies";
+
private StandardIndexRecordFields()
{
// No touchy!
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
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
{
expectedRecord.setRepository( "test" );
expectedRecord.setPackaging( "jar" );
expectedRecord.setProjectName( "Test JAR and POM" );
+ expectedRecord.setDependencies( createDependencies() );
+ expectedRecord.setDevelopers( createDevelopers() );
assertEquals( "check record", expectedRecord, record );
}
expectedRecord.setPackaging( "jar" );
expectedRecord.setProjectName( "Test JAR and POM" );
expectedRecord.setClassifier( "jdk14" );
+ expectedRecord.setDependencies( createDependencies() );
+ expectedRecord.setDevelopers( createDevelopers() );
assertEquals( "check record", expectedRecord, record );
}
expectedRecord.setProjectName( "Child Project" );
expectedRecord.setProjectDescription( "Description" );
expectedRecord.setInceptionYear( "2005" );
+ expectedRecord.setDependencies( Collections.singletonList( JUNIT_DEPENDENCY ) );
assertEquals( "check record", expectedRecord, record );
}
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 );
}
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;
+ }
}
<version>1.0-alpha-1</version>
<name>Test JAR and POM</name>
<dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
+ <developers>
+ <developer>
+ <id>brett</id>
+ <name>Brett Porter</name>
+ <email>brett@apache.org</email>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </developer>
+ </developers>
</project>