}
public static String mapExtensionAndClassifierToType( String classifier, String extension )
+ {
+ return mapExtensionAndClassifierToType( classifier, extension, extension );
+ }
+
+ public static String mapExtensionAndClassifierToType( String classifier, String extension,
+ String defaultExtension )
{
if ( "sources".equals( classifier ) )
{
{
return "javadoc";
}
- return mapExtensionToType( extension );
+ return mapExtensionToType( extension, defaultExtension );
}
public static String mapExtensionToType( String extension )
+ {
+ return mapExtensionToType( extension, extension );
+ }
+
+ private static String mapExtensionToType( String extension, String defaultExtension )
{
if ( "tar.gz".equals( extension ) )
{
{
return "distribution-zip";
}
- return extension;
+ return defaultExtension;
}
}
String extension = parser.getExtension();
// Set Type
- artifact.setType( ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension ) );
+ String defaultExtension = expectedType.substring( 0, expectedType.length() - 1 );
+ artifact.setType(
+ ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension, defaultExtension ) );
// Sanity Check: does it have an extension?
if ( StringUtils.isEmpty( artifact.getType() ) )
}
// Special Case with Maven Plugins
- if ( StringUtils.equals( "jar", artifact.getType() ) && StringUtils.equals( "plugins", expectedType ) )
+ if ( StringUtils.equals( "jar", extension ) && StringUtils.equals( "plugins", expectedType ) )
{
artifact.setType( ArtifactExtensionMapping.MAVEN_PLUGIN );
}
else
{
// Sanity Check: does extension match pathType on path?
- String trimPathType = expectedType.substring( 0, expectedType.length() - 1 );
-
- String expectedExtension = ArtifactExtensionMapping.getExtension( trimPathType );
+ String expectedExtension = ArtifactExtensionMapping.getExtension( artifact.getType() );
if ( !expectedExtension.equals( extension ) )
{
throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + extension
- + "] and layout specified type [" + expectedType + "] (which maps to extension: ["
+ + "] and layout specified type [" + artifact.getType() + "] (which maps to extension: ["
+ expectedExtension + "]) on path [" + path + "]" );
}
}
"org.apache.maven/java-sources/testing-1.0-sources.jar",
"org.apache.maven/jars/testing-1.0-20050611.112233-1.jar",
"org.apache.maven/poms/testing-1.0.pom",
+ "org.apache.maven/distributions/testing-1.0.tar.gz",
+ "org.apache.maven/distributions/testing-1.0.zip",
"org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar" };
StringBuffer relatedDebugString = new StringBuffer();
}
relatedDebugString.append( "]" );
- assertEquals( "Related <" + relatedDebugString + ">:", expected.length, related.size() );
-
for ( String expectedPath : expected )
{
boolean found = false;
+ "Related <" + relatedDebugString + ">" );
}
}
+ assertEquals( "Related <" + relatedDebugString + ">:", expected.length, related.size() );
}
@Override
ManagedRepositoryContent repository = createManagedRepo( "default" );
// Test (pom) legacy to default
- assertEquals( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", repoRequest
- .toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
+ assertEquals( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom",
+ repoRequest.toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
+ }
+
+ public void testNativePathPomLegacyToLegacy()
+ throws Exception
+ {
+ ManagedRepositoryContent repository = createManagedRepo( "legacy" );
+
+ // Test (pom) legacy to default
+ assertEquals( "org.apache.derby/poms/derby-10.2.2.0.pom",
+ repoRequest.toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
+ }
+
+ public void testNativePathPomLegacyToDefaultEjb()
+ throws Exception
+ {
+ ManagedRepositoryContent repository = createManagedRepo( "default" );
+
+ // Test (pom) legacy to default
+ assertEquals( "mygroup/myejb/1.0/myejb-1.0.jar",
+ repoRequest.toNativePath( "mygroup/ejbs/myejb-1.0.jar", repository ) );
+ }
+
+ public void testNativePathPomLegacyToLegacyEjb()
+ throws Exception
+ {
+ ManagedRepositoryContent repository = createManagedRepo( "legacy" );
+
+ // Test (pom) legacy to default
+ assertEquals( "mygroup/ejbs/myejb-1.0.jar",
+ repoRequest.toNativePath( "mygroup/ejbs/myejb-1.0.jar", repository ) );
}
public void testNativePathSupportFileLegacyToDefault()