mirror of https://github.com/apache/archiva.git
[MRM-161] clean up report results
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441391 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb314808e2
commit
b063f785e0
|
@ -45,12 +45,14 @@ public class DependencyArtifactReportProcessor
|
||||||
*/
|
*/
|
||||||
private RepositoryQueryLayerFactory layerFactory;
|
private RepositoryQueryLayerFactory layerFactory;
|
||||||
|
|
||||||
|
private static final String POM = "pom";
|
||||||
|
|
||||||
public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
|
public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
|
||||||
{
|
{
|
||||||
RepositoryQueryLayer queryLayer = layerFactory.createRepositoryQueryLayer( artifact.getRepository() );
|
RepositoryQueryLayer queryLayer = layerFactory.createRepositoryQueryLayer( artifact.getRepository() );
|
||||||
processArtifact( artifact, reporter, queryLayer );
|
processArtifact( artifact, reporter, queryLayer );
|
||||||
|
|
||||||
if ( model != null )
|
if ( model != null && POM.equals( artifact.getType() ) )
|
||||||
{
|
{
|
||||||
List dependencies = model.getDependencies();
|
List dependencies = model.getDependencies();
|
||||||
processDependencies( dependencies, reporter, queryLayer, artifact );
|
processDependencies( dependencies, reporter, queryLayer, artifact );
|
||||||
|
|
|
@ -62,7 +62,9 @@ public class DuplicateArtifactFileReportProcessor
|
||||||
{
|
{
|
||||||
ArtifactRepository repository = artifact.getRepository();
|
ArtifactRepository repository = artifact.getRepository();
|
||||||
// TODO! always null currently, need to configure this properly
|
// TODO! always null currently, need to configure this properly
|
||||||
if ( artifact.getFile() != null && indexDirectory != null )
|
if ( indexDirectory != null )
|
||||||
|
{
|
||||||
|
if ( artifact.getFile() != null )
|
||||||
{
|
{
|
||||||
RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ) );
|
RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ) );
|
||||||
|
|
||||||
|
@ -113,4 +115,5 @@ public class DuplicateArtifactFileReportProcessor
|
||||||
reporter.addWarning( artifact, "Artifact file is null" );
|
reporter.addWarning( artifact, "Artifact file is null" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.io.Reader;
|
||||||
/**
|
/**
|
||||||
* This class validates well-formedness of pom xml file.
|
* This class validates well-formedness of pom xml file.
|
||||||
*
|
*
|
||||||
|
* @todo nice to have this a specific, tested report - however it is likely to double up with project building exceptions from IndexerTask. Resolve [!]
|
||||||
* @plexus.component role="org.apache.maven.archiva.reporting.ArtifactReportProcessor" role-hint="invalid-pom"
|
* @plexus.component role="org.apache.maven.archiva.reporting.ArtifactReportProcessor" role-hint="invalid-pom"
|
||||||
*/
|
*/
|
||||||
public class InvalidPomArtifactReportProcessor
|
public class InvalidPomArtifactReportProcessor
|
||||||
|
@ -90,9 +91,5 @@ public class InvalidPomArtifactReportProcessor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
reporter.addWarning( artifact, "The artifact is not a pom xml file." );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,8 @@ public class LocationArtifactReportProcessor
|
||||||
*/
|
*/
|
||||||
private MavenProjectBuilder projectBuilder;
|
private MavenProjectBuilder projectBuilder;
|
||||||
|
|
||||||
|
private static final String POM = "pom";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the artifact is in its proper location. The location of the artifact
|
* Check whether the artifact is in its proper location. The location of the artifact
|
||||||
* is validated first against the groupId, artifactId and versionId in the specified model
|
* is validated first against the groupId, artifactId and versionId in the specified model
|
||||||
|
@ -82,17 +84,26 @@ public class LocationArtifactReportProcessor
|
||||||
String artifactPath = repository.pathOf( artifact );
|
String artifactPath = repository.pathOf( artifact );
|
||||||
|
|
||||||
if ( model != null )
|
if ( model != null )
|
||||||
|
{
|
||||||
|
// only check if it is a standalone POM, or an artifact other than a POM
|
||||||
|
// ie, don't check the location of the POM for another artifact matches that of the artifact
|
||||||
|
if ( !POM.equals( artifact.getType() ) || POM.equals( model.getPackaging() ) )
|
||||||
{
|
{
|
||||||
//check if the artifact is located in its proper location based on the info
|
//check if the artifact is located in its proper location based on the info
|
||||||
//specified in the model object/pom
|
//specified in the model object/pom
|
||||||
Artifact modelArtifact = artifactFactory.createBuildArtifact( model.getGroupId(), model.getArtifactId(),
|
Artifact modelArtifact = artifactFactory.createArtifactWithClassifier( model.getGroupId(),
|
||||||
model.getVersion(), model.getPackaging() );
|
model.getArtifactId(),
|
||||||
|
model.getVersion(),
|
||||||
|
artifact.getType(),
|
||||||
|
artifact.getClassifier() );
|
||||||
|
|
||||||
String modelPath = repository.pathOf( modelArtifact );
|
String modelPath = repository.pathOf( modelArtifact );
|
||||||
if ( !modelPath.equals( artifactPath ) )
|
if ( !modelPath.equals( artifactPath ) )
|
||||||
{
|
{
|
||||||
reporter.addFailure( artifact,
|
reporter.addFailure( artifact,
|
||||||
"The artifact is out of place. It does not match the specified location in the repository pom." );
|
"The artifact is out of place. It does not match the specified location in the repository pom: " +
|
||||||
|
modelPath );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +134,7 @@ public class LocationArtifactReportProcessor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reporter.addFailure( artifact,
|
throw new IllegalStateException( "Couldn't find artifact " + file );
|
||||||
"The artifact is out of place. It does not exist at the specified location in the repository pom." );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,6 @@ public class InvalidPomArtifactReportProcessorTest
|
||||||
|
|
||||||
artifactReportProcessor.processArtifact( artifact, null, reporter );
|
artifactReportProcessor.processArtifact( artifact, null, reporter );
|
||||||
assertEquals( 0, reporter.getNumFailures() );
|
assertEquals( 0, reporter.getNumFailures() );
|
||||||
assertEquals( 1, reporter.getNumWarnings() );
|
assertEquals( 0, reporter.getNumWarnings() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,41 @@ public class LocationArtifactReportProcessorTest
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1" );
|
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1" );
|
||||||
|
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
|
||||||
|
|
||||||
artifactReportProcessor.processArtifact( artifact, null, reporter );
|
Model model = readPom( repository.pathOf( pomArtifact ) );
|
||||||
|
artifactReportProcessor.processArtifact( artifact, model, reporter );
|
||||||
|
assertEquals( 0, reporter.getNumFailures() );
|
||||||
|
assertEquals( 0, reporter.getNumWarnings() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the LocationArtifactReporter when the artifact is in the location specified in the
|
||||||
|
* file system pom, but the pom itself is passed in.
|
||||||
|
*/
|
||||||
|
public void testLocationArtifactReporterSuccessPom()
|
||||||
|
throws IOException, XmlPullParserException
|
||||||
|
{
|
||||||
|
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
|
||||||
|
|
||||||
|
Model model = readPom( repository.pathOf( pomArtifact ) );
|
||||||
|
artifactReportProcessor.processArtifact( pomArtifact, model, reporter );
|
||||||
|
assertEquals( 0, reporter.getNumFailures() );
|
||||||
|
assertEquals( 0, reporter.getNumWarnings() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the LocationArtifactReporter when the artifact is in the location specified in the
|
||||||
|
* file system pom, with a classifier.
|
||||||
|
*/
|
||||||
|
public void testLocationArtifactReporterSuccessClassifier()
|
||||||
|
throws IOException, XmlPullParserException
|
||||||
|
{
|
||||||
|
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "java-source" );
|
||||||
|
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
|
||||||
|
|
||||||
|
Model model = readPom( repository.pathOf( pomArtifact ) );
|
||||||
|
artifactReportProcessor.processArtifact( artifact, model, reporter );
|
||||||
assertEquals( 0, reporter.getNumFailures() );
|
assertEquals( 0, reporter.getNumFailures() );
|
||||||
assertEquals( 0, reporter.getNumWarnings() );
|
assertEquals( 0, reporter.getNumWarnings() );
|
||||||
}
|
}
|
||||||
|
@ -90,9 +123,18 @@ public class LocationArtifactReportProcessorTest
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2" );
|
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2" );
|
||||||
|
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2", "pom" );
|
||||||
|
|
||||||
artifactReportProcessor.processArtifact( artifact, null, reporter );
|
try
|
||||||
assertEquals( 1, reporter.getNumFailures() );
|
{
|
||||||
|
Model model = readPom( repository.pathOf( pomArtifact ) );
|
||||||
|
artifactReportProcessor.processArtifact( artifact, model, reporter );
|
||||||
|
fail( "Should not have passed the artifact" );
|
||||||
|
}
|
||||||
|
catch ( IllegalStateException e )
|
||||||
|
{
|
||||||
|
// correct!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue