Author: brett
Date: Fri Sep 8 10:32:50 2006
New Revision: 441583
URL: http://svn.apache.org/viewvc?view=rev&rev=441583
Log:
[MRM-77] fix for reports for distributions that are non-standard types
Added:
maven/archiva/trunk/archiva-reports-standard/src/test/repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1-src.tar.gz
maven/archiva/trunk/archiva-reports-standard/src/test/repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1-src.zip
Modified:
maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessor.java
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java
Modified:
maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessor.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessor.java?view=diff&rev=441583&r1=441582&r2=441583
==============================================================================
---
maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessor.java
(original)
+++
maven/archiva/trunk/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessor.java
Fri Sep 8 10:32:50 2006
@@ -18,6 +18,7 @@
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;
@@ -81,6 +82,8 @@
"Can't process repository '" + repository.getUrl() + "'. Only
file based repositories are supported" );
}
+ adjustDistributionArtifactHandler( artifact );
+
String artifactPath = repository.pathOf( artifact );
if ( model != null )
@@ -97,6 +100,7 @@
artifact.getType(),
artifact.getClassifier() );
+ adjustDistributionArtifactHandler( modelArtifact );
String modelPath = repository.pathOf( modelArtifact );
if ( !modelPath.equals( artifactPath ) )
{
@@ -135,6 +139,19 @@
else
{
throw new IllegalStateException( "Couldn't find artifact " + file
);
+ }
+ }
+
+ 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"
) );
}
}
Modified:
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java?view=diff&rev=441583&r1=441582&r2=441583
==============================================================================
---
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java
(original)
+++
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/AbstractRepositoryReportsTestCase.java
Fri Sep 8 10:32:50 2006
@@ -64,4 +64,13 @@
return artifact;
}
+ protected Artifact createArtifactWithClassifier( String groupId, String
artifactId, String version, String type,
+ String classifier )
+ {
+ Artifact artifact =
+ artifactFactory.createArtifactWithClassifier( groupId, artifactId,
version, type, classifier );
+ artifact.setRepository( repository );
+ return artifact;
+ }
+
}
Modified:
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java?view=diff&rev=441583&r1=441582&r2=441583
==============================================================================
---
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java
(original)
+++
maven/archiva/trunk/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/LocationArtifactReportProcessorTest.java
Fri Sep 8 10:32:50 2006
@@ -46,14 +46,6 @@
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.
@@ -107,6 +99,40 @@
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.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 ) );
Added:
maven/archiva/trunk/archiva-reports-standard/src/test/repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1-src.tar.gz
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1-src.tar.gz?view=auto&rev=441583
==============================================================================
Binary files /tmp/tmpcXM7si and /tmp/tmpUvWobo differ
Added:
maven/archiva/trunk/archiva-reports-standard/src/test/repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1-src.zip
URL:
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-reports-standard/src/test/repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1-src.zip?view=auto&rev=441583
==============================================================================
Binary files /tmp/tmpEWCF2M and /tmp/tmp-v__gL differ