mirror of https://github.com/apache/archiva.git
[MRM-151] index developers and dependencies
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@437165 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87fef8ad23
commit
90b48267d7
|
@ -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 ) );
|
||||
|
|
|
@ -96,6 +96,16 @@ public class StandardArtifactIndexRecord
|
|||
*/
|
||||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
<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>
|
||||
|
@ -29,4 +34,14 @@
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue