diff options
author | Brett Porter <brett@apache.org> | 2010-12-31 00:53:23 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2010-12-31 00:53:23 +0000 |
commit | 91a012ebdd549e877a7cadd6774bce2eaba59170 (patch) | |
tree | 185e14352d574531136e3b627bfa50a5371480d4 | |
parent | 8aacc3cd0b9612a39e7cc5ffded984c845330f3e (diff) | |
download | archiva-91a012ebdd549e877a7cadd6774bce2eaba59170.tar.gz archiva-91a012ebdd549e877a7cadd6774bce2eaba59170.zip |
[MRM-1448] additional '.' in the classifier & extension should be attributed to the extension instead of the classifier.
Note that existing records will not be updated - the repository may need to be re-scanned to reflect the change.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1054034 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 71 insertions, 16 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultPathParser.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultPathParser.java index 1c478f08c..0246b1384 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultPathParser.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultPathParser.java @@ -34,11 +34,13 @@ import java.util.Collections; /** * DefaultPathParser is a parser for maven 2 (default layout) paths to ArtifactReference. * - * TODO: remove in favour of path translator, this is just delegating for the most part + * TODO: remove in favour of path translator, this is just delegating for the most part, but won't accommodate other + * extensions like NPanday * * @version $Id$ */ -public class DefaultPathParser implements PathParser +public class DefaultPathParser + implements PathParser { private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: "; @@ -47,6 +49,7 @@ public class DefaultPathParser implements PathParser /** * {@inheritDoc} + * * @see org.apache.maven.archiva.repository.content.PathParser#toArtifactReference(java.lang.String) */ public ArtifactReference toArtifactReference( String path ) @@ -77,7 +80,7 @@ public class DefaultPathParser implements PathParser artifact.setClassifier( facet.getClassifier() ); artifact.setType( facet.getType() ); } - + return artifact; } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/DefaultPathParserTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/DefaultPathParserTest.java index 97a50418e..0d1a48756 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/DefaultPathParserTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/DefaultPathParserTest.java @@ -27,6 +27,8 @@ import org.apache.maven.archiva.repository.layout.LayoutException; /** * DefaultPathParserTest * + * TODO: move to path translator tests + * * @version $Id$ */ public class DefaultPathParserTest @@ -42,7 +44,8 @@ public class DefaultPathParserTest public void testBadPathReleaseInSnapshotDir() { - assertBadPath( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar", "non snapshot artifact inside of a snapshot dir" ); + assertBadPath( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar", + "non snapshot artifact inside of a snapshot dir" ); } public void testBadPathTimestampedSnapshotNotInSnapshotDir() @@ -88,9 +91,49 @@ public class DefaultPathParserTest assertLayout( path, groupId, artifactId, version, classifier, type ); } + public void testGoodButDualExtensionsWithClassifier() + throws LayoutException + { + String groupId = "org.project"; + String artifactId = "example-presentation"; + String version = "3.2"; + String classifier = "extras"; + String type = "xml.zip"; + String path = "org/project/example-presentation/3.2/example-presentation-3.2-extras.xml.zip"; + + assertLayout( path, groupId, artifactId, version, classifier, type ); + } + + public void testGoodButDualExtensionsTarGz() + throws LayoutException + { + String groupId = "org.project"; + String artifactId = "example-distribution"; + String version = "1.3"; + String classifier = null; + String type = "tar.gz"; // no longer using distribution-tgz / distribution-zip in maven 2 + String path = "org/project/example-distribution/1.3/example-distribution-1.3.tar.gz"; + + assertLayout( path, groupId, artifactId, version, classifier, type ); + } + + public void testGoodButDualExtensionsTarGzAndClassifier() + throws LayoutException + { + String groupId = "org.project"; + String artifactId = "example-distribution"; + String version = "1.3"; + String classifier = "bin"; + String type = "tar.gz"; // no longer using distribution-tgz / distribution-zip in maven 2 + String path = "org/project/example-distribution/1.3/example-distribution-1.3-bin.tar.gz"; + + assertLayout( path, groupId, artifactId, version, classifier, type ); + } + /** * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. + * * @throws LayoutException */ public void testGoodButOddVersionSpecGanymedSsh2() @@ -109,6 +152,7 @@ public class DefaultPathParserTest /** * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. + * * @throws LayoutException */ public void testGoodButOddVersionSpecJavaxComm() @@ -148,6 +192,7 @@ public class DefaultPathParserTest /** * [MRM-432] Oddball version spec. * Example of an oddball / unusual version spec. + * * @throws LayoutException */ public void testGoodButOddVersionSpecJavaxPersistence() @@ -252,13 +297,15 @@ public class DefaultPathParserTest String version = "0.3"; String classifier = null; String type = "pom"; - String path = "com/company/department/com.company.department.project/0.3/com.company.department.project-0.3.pom"; + String path = + "com/company/department/com.company.department.project/0.3/com.company.department.project-0.3.pom"; assertLayout( path, groupId, artifactId, version, classifier, type ); } /** * Test the classifier, and java-source type spec. + * * @throws LayoutException */ public void testGoodFooLibSources() @@ -276,6 +323,7 @@ public class DefaultPathParserTest /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. + * * @throws LayoutException */ public void testGoodSnapshotMavenTest() @@ -286,13 +334,15 @@ public class DefaultPathParserTest String version = "3.1-beta-1-20050831.101112-42"; String classifier = null; String type = "jar"; - String path = "org/apache/archiva/test/redonkulous/3.1-beta-1-SNAPSHOT/redonkulous-3.1-beta-1-20050831.101112-42.jar"; + String path = + "org/apache/archiva/test/redonkulous/3.1-beta-1-SNAPSHOT/redonkulous-3.1-beta-1-20050831.101112-42.jar"; assertLayout( path, groupId, artifactId, version, classifier, type ); } /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. + * * @throws LayoutException */ public void testGoodLongSnapshotMavenTest() @@ -309,16 +359,17 @@ public class DefaultPathParserTest } /** - * A timestamped versioned artifact but without release version part. Like on axiom trunk. + * A timestamped versioned artifact but without release version part. Like on axiom trunk. */ public void testBadSnapshotWithoutReleasePart() { - assertBadPath( "org/apache/ws/commons/axiom/axiom/SNAPSHOT/axiom-20070912.093446-2.pom", - "snapshot version without release part"); + assertBadPath( "org/apache/ws/commons/axiom/axiom/SNAPSHOT/axiom-20070912.093446-2.pom", + "snapshot version without release part" ); } /** * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. + * * @throws LayoutException */ public void testClassifiedSnapshotMavenTest() @@ -451,8 +502,8 @@ public class DefaultPathParserTest private void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId, String version, String classifier, String type ) { - String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier - + ":" + type; + String expectedId = + "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; assertNotNull( expectedId + " - Should not be null.", actualReference ); @@ -471,7 +522,8 @@ public class DefaultPathParserTest try { parser.toArtifactReference( path ); - fail( "Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); + fail( + "Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); } catch ( LayoutException e ) { diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java index b3f8e1cc7..26982c48b 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryPathTranslator.java @@ -166,7 +166,7 @@ public class Maven2RepositoryPathTranslator if ( !id.startsWith( projectId + "-" ) ) { throw new IllegalArgumentException( "Not a valid artifact path in a Maven 2 repository, filename '" + id + - "' doesn't start with artifact ID '" + projectId + "'" ); + "' doesn't start with artifact ID '" + projectId + "'" ); } MavenArtifactFacet facet = new MavenArtifactFacet(); @@ -228,9 +228,9 @@ public class Maven2RepositoryPathTranslator char c = id.charAt( index ); if ( c == '-' ) { - // classifier up until last '.' - int extIndex = id.lastIndexOf( '.' ); - if ( extIndex > index ) + // classifier up until '.' + int extIndex = id.indexOf( '.', index ); + if ( extIndex >= 0 ) { classifier = id.substring( index + 1, extIndex ); ext = id.substring( extIndex + 1 ); |