mirror of https://github.com/apache/archiva.git
[MRM-674] correct problems with test-sources classifier and alternate version approaches
Merged from: r630092,r630094 on archiva-1.0.x branch git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@630098 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5f27f502ff
commit
ee66759481
|
@ -44,7 +44,7 @@ public class VersionUtil
|
||||||
"(alpha[_.0-9]*)",
|
"(alpha[_.0-9]*)",
|
||||||
"(beta[_.0-9]*)",
|
"(beta[_.0-9]*)",
|
||||||
"(rc[_.0-9]*)",
|
"(rc[_.0-9]*)",
|
||||||
"(test[_.0-9]*)",
|
// "(test[_.0-9]*)", -- omitted for MRM-681, can be reinstated as part of MRM-712
|
||||||
"(debug[_.0-9]*)",
|
"(debug[_.0-9]*)",
|
||||||
"(unofficial[_.0-9]*)",
|
"(unofficial[_.0-9]*)",
|
||||||
"(current)",
|
"(current)",
|
||||||
|
@ -57,8 +57,6 @@ public class VersionUtil
|
||||||
"(incubator)",
|
"(incubator)",
|
||||||
"([ab][_.0-9]+)" };
|
"([ab][_.0-9]+)" };
|
||||||
|
|
||||||
private static final String VersionMegaPattern = StringUtils.join( versionPatterns, '|' );
|
|
||||||
|
|
||||||
public static final String SNAPSHOT = "SNAPSHOT";
|
public static final String SNAPSHOT = "SNAPSHOT";
|
||||||
|
|
||||||
public static final Pattern UNIQUE_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$" );
|
public static final Pattern UNIQUE_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$" );
|
||||||
|
@ -67,6 +65,8 @@ public class VersionUtil
|
||||||
|
|
||||||
public static final Pattern GENERIC_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-" + SNAPSHOT );
|
public static final Pattern GENERIC_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-" + SNAPSHOT );
|
||||||
|
|
||||||
|
private static final Pattern VERSION_MEGA_PATTERN = Pattern.compile( StringUtils.join( versionPatterns, '|' ), Pattern.CASE_INSENSITIVE );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Tests if the unknown string contains elements that identify it as a version string (or not).
|
* Tests if the unknown string contains elements that identify it as a version string (or not).
|
||||||
|
@ -85,7 +85,6 @@ public class VersionUtil
|
||||||
{
|
{
|
||||||
String versionParts[] = StringUtils.split( unknown, '-' );
|
String versionParts[] = StringUtils.split( unknown, '-' );
|
||||||
|
|
||||||
Pattern pat = Pattern.compile( VersionMegaPattern, Pattern.CASE_INSENSITIVE );
|
|
||||||
Matcher mat;
|
Matcher mat;
|
||||||
|
|
||||||
int countValidParts = 0;
|
int countValidParts = 0;
|
||||||
|
@ -93,7 +92,7 @@ public class VersionUtil
|
||||||
for ( int i = 0; i < versionParts.length; i++ )
|
for ( int i = 0; i < versionParts.length; i++ )
|
||||||
{
|
{
|
||||||
String part = versionParts[i];
|
String part = versionParts[i];
|
||||||
mat = pat.matcher( part );
|
mat = VERSION_MEGA_PATTERN.matcher( part );
|
||||||
|
|
||||||
if ( mat.matches() )
|
if ( mat.matches() )
|
||||||
{
|
{
|
||||||
|
@ -124,8 +123,7 @@ public class VersionUtil
|
||||||
*/
|
*/
|
||||||
public static boolean isSimpleVersionKeyword( String identifier )
|
public static boolean isSimpleVersionKeyword( String identifier )
|
||||||
{
|
{
|
||||||
Pattern pat = Pattern.compile( VersionMegaPattern, Pattern.CASE_INSENSITIVE );
|
Matcher mat = VERSION_MEGA_PATTERN.matcher( identifier );
|
||||||
Matcher mat = pat.matcher( identifier );
|
|
||||||
|
|
||||||
return mat.matches();
|
return mat.matches();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,8 @@ package org.apache.maven.archiva.repository.content;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArtifactExtensionMapping
|
* ArtifactExtensionMapping
|
||||||
|
@ -38,9 +34,9 @@ public class ArtifactClassifierMapping
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
typeToClassifierMap = new HashMap<String, String>();
|
typeToClassifierMap = new HashMap<String, String>();
|
||||||
typeToClassifierMap.put( "java-source", "sources" );
|
typeToClassifierMap.put( "java-sources", "sources" );
|
||||||
typeToClassifierMap.put( "javadoc.jar", "javadoc" );
|
typeToClassifierMap.put( "javadoc.jars", "javadoc" );
|
||||||
typeToClassifierMap.put( "javadoc", "javadoc" );
|
typeToClassifierMap.put( "javadocs", "javadoc" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getClassifier( String type )
|
public static String getClassifier( String type )
|
||||||
|
|
|
@ -19,9 +19,6 @@ package org.apache.maven.archiva.repository.content;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -70,52 +67,6 @@ public class ArtifactExtensionMapping
|
||||||
return type.replace( '-', '.' );
|
return type.replace( '-', '.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String guessTypeFromFilename( File file )
|
|
||||||
{
|
|
||||||
return guessTypeFromFilename( file.getName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String guessTypeFromFilename( String filename )
|
|
||||||
{
|
|
||||||
if ( StringUtils.isBlank( filename ) )
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String normalizedName = filename.toLowerCase().trim();
|
|
||||||
int idx = normalizedName.lastIndexOf( '.' );
|
|
||||||
|
|
||||||
if ( idx == ( -1 ) )
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( normalizedName.endsWith( ".tar.gz" ) )
|
|
||||||
{
|
|
||||||
return "distribution-tgz";
|
|
||||||
}
|
|
||||||
if ( normalizedName.endsWith( ".tar.bz2" ) )
|
|
||||||
{
|
|
||||||
return "distribution-bzip";
|
|
||||||
}
|
|
||||||
else if ( normalizedName.endsWith( ".zip" ) )
|
|
||||||
{
|
|
||||||
return "distribution-zip";
|
|
||||||
}
|
|
||||||
else if ( normalizedName.endsWith( "-sources.jar" ) )
|
|
||||||
{
|
|
||||||
return "java-source";
|
|
||||||
}
|
|
||||||
else if ( normalizedName.endsWith( "-javadoc.jar" ) )
|
|
||||||
{
|
|
||||||
return "javadoc";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return normalizedName.substring( idx + 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a given artifact Id conforms to the naming scheme for a maven plugin.
|
* Determine if a given artifact Id conforms to the naming scheme for a maven plugin.
|
||||||
*
|
*
|
||||||
|
@ -126,4 +77,34 @@ public class ArtifactExtensionMapping
|
||||||
{
|
{
|
||||||
return mavenPluginPattern.matcher( artifactId ).matches();
|
return mavenPluginPattern.matcher( artifactId ).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String mapExtensionAndClassifierToType( String classifier, String extension )
|
||||||
|
{
|
||||||
|
if ( "sources".equals( classifier ) )
|
||||||
|
{
|
||||||
|
return "java-source";
|
||||||
|
}
|
||||||
|
else if ( "javadoc".equals( classifier ) )
|
||||||
|
{
|
||||||
|
return "javadoc";
|
||||||
|
}
|
||||||
|
return mapExtensionToType( extension );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String mapExtensionToType( String extension )
|
||||||
|
{
|
||||||
|
if ( extension.equals( "tar.gz" ) )
|
||||||
|
{
|
||||||
|
return "distribution-tgz";
|
||||||
|
}
|
||||||
|
else if ( extension.equals( "tar.bz2" ) )
|
||||||
|
{
|
||||||
|
return "distribution-bzip";
|
||||||
|
}
|
||||||
|
else if ( extension.equals( "zip" ) )
|
||||||
|
{
|
||||||
|
return "distribution-zip";
|
||||||
|
}
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class DefaultPathParser implements PathParser
|
||||||
artifact.setClassifier( parser.remaining() );
|
artifact.setClassifier( parser.remaining() );
|
||||||
|
|
||||||
// Set the type.
|
// Set the type.
|
||||||
artifact.setType( ArtifactExtensionMapping.guessTypeFromFilename( filename ) );
|
artifact.setType( ArtifactExtensionMapping.mapExtensionAndClassifierToType( artifact.getClassifier(), parser.getExtension() ) );
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
// We have an dual extension possibility.
|
// We have an dual extension possibility.
|
||||||
|
@ -156,7 +156,7 @@ public class DefaultPathParser implements PathParser
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// End of the filename, only a simple extension left. - Set the type.
|
// End of the filename, only a simple extension left. - Set the type.
|
||||||
artifact.setType( ArtifactExtensionMapping.guessTypeFromFilename( filename ) );
|
artifact.setType( ArtifactExtensionMapping.mapExtensionToType( parser.getExtension() ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,10 @@ public class FilenameParser
|
||||||
|
|
||||||
private static final Pattern mavenPluginPattern = Pattern.compile( "(maven-.*-plugin)|(.*-maven-plugin)" );
|
private static final Pattern mavenPluginPattern = Pattern.compile( "(maven-.*-plugin)|(.*-maven-plugin)" );
|
||||||
|
|
||||||
private static final Pattern extensionPattern = Pattern.compile( "(.tar.gz$)|(.tar.bz2$)|(.[a-z0-9]*$)",
|
private static final Pattern extensionPattern =
|
||||||
Pattern.CASE_INSENSITIVE );
|
Pattern.compile( "(.tar.gz$)|(.tar.bz2$)|(.[a-z0-9]*$)", Pattern.CASE_INSENSITIVE );
|
||||||
|
|
||||||
|
private static final Pattern SNAPSHOT_PATTERN = Pattern.compile( "^([0-9]{8}\\.[0-9]{6}-[0-9]+)(.*)$" );
|
||||||
|
|
||||||
private static final Pattern section = Pattern.compile( "([^-]*)" );
|
private static final Pattern section = Pattern.compile( "([^-]*)" );
|
||||||
|
|
||||||
|
@ -90,16 +92,39 @@ public class FilenameParser
|
||||||
|
|
||||||
protected String expect( String expected )
|
protected String expect( String expected )
|
||||||
{
|
{
|
||||||
|
String value = null;
|
||||||
|
|
||||||
if ( name.startsWith( expected, offset ) )
|
if ( name.startsWith( expected, offset ) )
|
||||||
|
{
|
||||||
|
value = expected;
|
||||||
|
}
|
||||||
|
else if ( VersionUtil.isGenericSnapshot( expected ) )
|
||||||
|
{
|
||||||
|
String version = name.substring( offset );
|
||||||
|
|
||||||
|
// check it starts with the same version up to the snapshot part
|
||||||
|
int leadingLength = expected.length() - 9;
|
||||||
|
if ( version.startsWith( expected.substring( 0, leadingLength ) ) && version.length() > leadingLength )
|
||||||
|
{
|
||||||
|
// If we expect a non-generic snapshot - look for the timestamp
|
||||||
|
Matcher m = SNAPSHOT_PATTERN.matcher( version.substring( leadingLength + 1 ) );
|
||||||
|
if ( m.matches() )
|
||||||
|
{
|
||||||
|
value = version.substring( 0, leadingLength + 1 ) + m.group( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( value != null )
|
||||||
{
|
{
|
||||||
// Potential hit. check for '.' or '-' at end of expected.
|
// Potential hit. check for '.' or '-' at end of expected.
|
||||||
int seperatorOffset = offset + expected.length();
|
int seperatorOffset = offset + value.length();
|
||||||
|
|
||||||
// Test for "out of bounds" first.
|
// Test for "out of bounds" first.
|
||||||
if ( seperatorOffset >= name.length() )
|
if ( seperatorOffset >= name.length() )
|
||||||
{
|
{
|
||||||
offset = name.length();
|
offset = name.length();
|
||||||
return expected;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for seperator char.
|
// Test for seperator char.
|
||||||
|
@ -107,7 +132,7 @@ public class FilenameParser
|
||||||
if ( ( seperatorChar == '-' ) || ( seperatorChar == '.' ) )
|
if ( ( seperatorChar == '-' ) || ( seperatorChar == '.' ) )
|
||||||
{
|
{
|
||||||
offset = seperatorOffset + 1;
|
offset = seperatorOffset + 1;
|
||||||
return expected;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,15 @@ package org.apache.maven.archiva.repository.content;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
||||||
import org.apache.maven.archiva.model.ArtifactReference;
|
import org.apache.maven.archiva.model.ArtifactReference;
|
||||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LegacyPathParser is a parser for maven 1 (legacy layout) paths to
|
* LegacyPathParser is a parser for maven 1 (legacy layout) paths to
|
||||||
* ArtifactReference.
|
* ArtifactReference.
|
||||||
|
@ -163,8 +162,23 @@ public class LegacyPathParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String classifier = ArtifactClassifierMapping.getClassifier( expectedType );
|
||||||
|
if ( classifier != null )
|
||||||
|
{
|
||||||
|
String version = artifact.getVersion();
|
||||||
|
if ( ! version.endsWith( "-" + classifier ) )
|
||||||
|
{
|
||||||
|
throw new LayoutException( INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier );
|
||||||
|
}
|
||||||
|
version = version.substring( 0, version.length() - classifier.length() - 1 );
|
||||||
|
artifact.setVersion( version );
|
||||||
|
artifact.setClassifier( classifier );
|
||||||
|
}
|
||||||
|
|
||||||
|
String extension = parser.getExtension();
|
||||||
|
|
||||||
// Set Type
|
// Set Type
|
||||||
artifact.setType( ArtifactExtensionMapping.guessTypeFromFilename( filename ) );
|
artifact.setType( ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension ) );
|
||||||
|
|
||||||
// Sanity Check: does it have an extension?
|
// Sanity Check: does it have an extension?
|
||||||
if ( StringUtils.isEmpty( artifact.getType() ) )
|
if ( StringUtils.isEmpty( artifact.getType() ) )
|
||||||
|
@ -183,29 +197,15 @@ public class LegacyPathParser
|
||||||
String trimPathType = expectedType.substring( 0, expectedType.length() - 1 );
|
String trimPathType = expectedType.substring( 0, expectedType.length() - 1 );
|
||||||
|
|
||||||
String expectedExtension = ArtifactExtensionMapping.getExtension( trimPathType );
|
String expectedExtension = ArtifactExtensionMapping.getExtension( trimPathType );
|
||||||
String actualExtension = parser.getExtension();
|
|
||||||
|
|
||||||
if ( !expectedExtension.equals( actualExtension ) )
|
if ( !expectedExtension.equals( extension ) )
|
||||||
{
|
{
|
||||||
throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + actualExtension
|
throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + extension
|
||||||
+ "] and layout specified type [" + expectedType + "] (which maps to extension: ["
|
+ "] and layout specified type [" + expectedType + "] (which maps to extension: ["
|
||||||
+ expectedExtension + "]) on path [" + path + "]" );
|
+ expectedExtension + "]) on path [" + path + "]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String classifier = ArtifactClassifierMapping.getClassifier( artifact.getType() );
|
|
||||||
if ( classifier != null )
|
|
||||||
{
|
|
||||||
String version = artifact.getVersion();
|
|
||||||
if ( ! version.endsWith( "-" + classifier ) )
|
|
||||||
{
|
|
||||||
throw new LayoutException( INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier );
|
|
||||||
}
|
|
||||||
version = version.substring( 0, version.length() - classifier.length() - 1 );
|
|
||||||
artifact.setVersion( version );
|
|
||||||
artifact.setClassifier( classifier );
|
|
||||||
}
|
|
||||||
|
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,40 @@ public class DefaultPathParserTest
|
||||||
assertLayout( path, groupId, artifactId, version, classifier, type );
|
assertLayout( path, groupId, artifactId, version, classifier, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory.
|
||||||
|
* @throws LayoutException
|
||||||
|
*/
|
||||||
|
public void testGoodLongSnapshotMavenTest()
|
||||||
|
throws LayoutException
|
||||||
|
{
|
||||||
|
String groupId = "a.group.id";
|
||||||
|
String artifactId = "artifact-id";
|
||||||
|
String version = "1.0-abc-1.1-20080221.062205-9";
|
||||||
|
String classifier = null;
|
||||||
|
String type = "pom";
|
||||||
|
String path = "a/group/id/artifact-id/1.0-abc-1.1-SNAPSHOT/artifact-id-1.0-abc-1.1-20080221.062205-9.pom";
|
||||||
|
|
||||||
|
assertLayout( path, groupId, artifactId, version, classifier, type );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory.
|
||||||
|
* @throws LayoutException
|
||||||
|
*/
|
||||||
|
public void testClassifiedSnapshotMavenTest()
|
||||||
|
throws LayoutException
|
||||||
|
{
|
||||||
|
String groupId = "a.group.id";
|
||||||
|
String artifactId = "artifact-id";
|
||||||
|
String version = "1.0-20070219.171202-34";
|
||||||
|
String classifier = "test-sources";
|
||||||
|
String type = "jar";
|
||||||
|
String path = "a/group/id/artifact-id/1.0-SNAPSHOT/artifact-id-1.0-20070219.171202-34-test-sources.jar";
|
||||||
|
|
||||||
|
assertLayout( path, groupId, artifactId, version, classifier, type );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [MRM-519] version identifiers within filename cause misidentification of version.
|
* [MRM-519] version identifiers within filename cause misidentification of version.
|
||||||
* Example uses "test" in artifact Id, which is also part of the versionKeyword list.
|
* Example uses "test" in artifact Id, which is also part of the versionKeyword list.
|
||||||
|
|
|
@ -149,4 +149,34 @@ public class FilenameParserTest
|
||||||
assertEquals( "libfobs4jmf-0.4.1.4-20080217.211715-4", parser.getName() );
|
assertEquals( "libfobs4jmf-0.4.1.4-20080217.211715-4", parser.getName() );
|
||||||
assertEquals( "jnilib", parser.getExtension() );
|
assertEquals( "jnilib", parser.getExtension() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInterveningVersion()
|
||||||
|
{
|
||||||
|
FilenameParser parser = new FilenameParser( "artifact-id-1.0-abc-1.1-20080221.062205-9.pom" );
|
||||||
|
|
||||||
|
assertEquals( "artifact-id", parser.nextNonVersion() );
|
||||||
|
assertEquals( "1.0-abc-1.1-20080221.062205-9", parser.expect( "1.0-abc-1.1-SNAPSHOT" ) );
|
||||||
|
assertNull( null, parser.remaining() );
|
||||||
|
assertEquals( "artifact-id-1.0-abc-1.1-20080221.062205-9", parser.getName() );
|
||||||
|
assertEquals( "pom", parser.getExtension() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testExpectWrongSnapshot()
|
||||||
|
{
|
||||||
|
FilenameParser parser = new FilenameParser( "artifact-id-1.0-20080221.062205-9.pom" );
|
||||||
|
|
||||||
|
assertEquals( "artifact-id", parser.nextNonVersion() );
|
||||||
|
assertNull( parser.expect( "2.0-SNAPSHOT" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testClassifier()
|
||||||
|
{
|
||||||
|
FilenameParser parser = new FilenameParser( "artifact-id-1.0-20070219.171202-34-test-sources.jar" );
|
||||||
|
|
||||||
|
assertEquals( "artifact-id", parser.nextNonVersion() );
|
||||||
|
assertEquals( "1.0-20070219.171202-34", parser.nextVersion() );
|
||||||
|
assertEquals( "test-sources", parser.remaining() );
|
||||||
|
assertEquals( "artifact-id-1.0-20070219.171202-34-test-sources", parser.getName() );
|
||||||
|
assertEquals( "jar", parser.getExtension() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.maven.archiva.repository.content;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.DefaultArchivaConfiguration;
|
|
||||||
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
import org.apache.maven.archiva.configuration.LegacyArtifactPath;
|
||||||
import org.apache.maven.archiva.model.ArtifactReference;
|
import org.apache.maven.archiva.model.ArtifactReference;
|
||||||
import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
|
import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
|
||||||
|
@ -212,6 +211,8 @@ public class LegacyPathParserTest
|
||||||
String path = "com.foo.lib/javadoc.jars/foo-lib-2.1-alpha-1-javadoc.jar";
|
String path = "com.foo.lib/javadoc.jars/foo-lib-2.1-alpha-1-javadoc.jar";
|
||||||
|
|
||||||
assertLayout( path, groupId, artifactId, version, classifier, type );
|
assertLayout( path, groupId, artifactId, version, classifier, type );
|
||||||
|
|
||||||
|
assertLayout( "com.foo.lib/javadocs/foo-lib-2.1-alpha-1-javadoc.jar", "com.foo.lib", "foo-lib", "2.1-alpha-1", "javadoc", "javadoc" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,6 +232,35 @@ public class LegacyPathParserTest
|
||||||
assertLayout( path, groupId, artifactId, version, classifier, type );
|
assertLayout( path, groupId, artifactId, version, classifier, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the classifier, and java-source type spec.
|
||||||
|
* @throws LayoutException
|
||||||
|
*/
|
||||||
|
public void testBadClassifierFooLibSources()
|
||||||
|
throws LayoutException
|
||||||
|
{
|
||||||
|
assertBadPath( "com.foo.lib/java-sources/foo-lib-2.1-alpha-1.jar", "missing required classifier" );
|
||||||
|
assertBadPath( "com.foo.lib/java-sources/foo-lib-2.1-alpha-1-javadoc.jar", "incorrect classifier" );
|
||||||
|
assertBadPath( "com.foo.lib/java-sources/foo-lib-2.1-alpha-1-other.jar", "incorrect classifier" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the classifier, and java-source type spec.
|
||||||
|
* @throws LayoutException
|
||||||
|
*/
|
||||||
|
public void testGoodFooLibTestSources()
|
||||||
|
throws LayoutException
|
||||||
|
{
|
||||||
|
String groupId = "com.foo.lib";
|
||||||
|
String artifactId = "foo-lib";
|
||||||
|
String version = "2.1-alpha-1-test-sources";
|
||||||
|
String type = "jar";
|
||||||
|
String classifier = null; // we can't parse this type of classifier in legacy format
|
||||||
|
String path = "com.foo.lib/jars/foo-lib-2.1-alpha-1-test-sources.jar";
|
||||||
|
|
||||||
|
assertLayout( path, groupId, artifactId, version, classifier, type );
|
||||||
|
}
|
||||||
|
|
||||||
public void testGoodFooTool()
|
public void testGoodFooTool()
|
||||||
throws LayoutException
|
throws LayoutException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue