import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
"Can't process repository '" + repository.getUrl() + "'. Only file based repositories are supported" );
}
+ adjustDistributionArtifactHandler( artifact );
+
String artifactPath = repository.pathOf( artifact );
if ( model != null )
artifact.getType(),
artifact.getClassifier() );
+ adjustDistributionArtifactHandler( modelArtifact );
String modelPath = repository.pathOf( modelArtifact );
if ( !modelPath.equals( artifactPath ) )
{
}
}
+ private static void adjustDistributionArtifactHandler( Artifact artifact )
+ {
+ // need to tweak these as they aren't currently in the known type converters. TODO - add them in Maven
+ if ( "distribution-zip".equals( artifact.getType() ) )
+ {
+ artifact.setArtifactHandler( new DefaultArtifactHandler( "zip" ) );
+ }
+ else if ( "distribution-tgz".equals( artifact.getType() ) )
+ {
+ artifact.setArtifactHandler( new DefaultArtifactHandler( "tar.gz" ) );
+ }
+ }
+
private Model readArtifactModel( File file, Artifact artifact, ReportingDatabase reporter )
{
Model model = null;
pomReader = new MavenXpp3Reader();
}
- public void tearDown()
- throws Exception
- {
- super.tearDown();
- artifactReportProcessor = null;
- pomReader = null;
- }
-
/**
* Test the LocationArtifactReporter when the artifact's physical location matches the location specified
* both in the file system pom and in the pom included in the package.
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 testLocationArtifactReporterSuccessZip()
+ throws IOException, XmlPullParserException
+ {
+ Artifact artifact =
+ createArtifactWithClassifier( "groupId", "artifactId", "1.0-alpha-1", "distribution-zip", "src" );
+ 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.getNumWarnings() );
+ }
+
+ /**
+ * Test the LocationArtifactReporter when the artifact is in the location specified in the
+ * file system pom, with a classifier.
+ */
+ public void testLocationArtifactReporterSuccessTgz()
+ throws IOException, XmlPullParserException
+ {
+ Artifact artifact =
+ createArtifactWithClassifier( "groupId", "artifactId", "1.0-alpha-1", "distribution-tgz", "src" );
+ 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.getNumWarnings() );
+ }
+
/**
* Test the LocationArtifactReporter when the artifact is not in the location specified
* in the file system pom.