Archiva

regression : cannot get java-sources anymore from maven1

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-beta-4
  • Fix Version/s: 1.0
  • Component/s: WebDAV Interface
  • Labels:
    None
  • Number of attachments :
    1

Description

requesting "junit/java-sources/junit-3.8.1-sources.jar" fails.

Path is converted internally to
groupId = junit
artifactId = junit
version = 3.8.1-sources
type = jar

I can publish a fix for this, but my workspace contains other modified code and I can hardly create a dedicated patch.

The idea is to create a ArtifactClassifierMapping similar to existing ArtifactExtensionMapping, and to use it in LegacyPathParser :

// Sanity Check: does extension match pathType on path?
String trimPathType = expectedType.substring( 0, expectedType.length() - 1 );

String expectedExtension = ArtifactExtensionMapping.getExtension( trimPathType );

artifact.setType( expectedExtension );
String classifier = ArtifactClassifierMapping.getClassifier( trimPathType );
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 );
}

Activity

Hide
nicolas de loof added a comment - - edited

The attached patch must be applied on archiva-repository-layer

it also require to :

  • rename \src\test\repositories\legacy-repository\org.apache.maven\javadocs to javadoc.jars (in conformance to maven 1 javadoc plugin)
  • move \src\test\repositories\legacy-repository\org.apache.maven\jars\testing-1.0-sources.jar to \src\test\repositories\legacy-repository\org.apache.maven\java-sources (in conformance to maven 1 source plugin).

Those two changes where not handled by my patch tool, as configured to binary types.

The idea of the patch is :

  • remove the assertion that legacy path have no classifier. Simply have no way to support unstandard classifiers.
  • automatically use "-javadoc" and "-sources" classifiers for path with types "javadoc.jars" and "java-sources". Check for the classifier to be detected in the version string and remove it.

The patch contains

  • modified code base
  • updated test cases. Thanks to Joakim, this part has good test coverage and new tests are easy to add.

This will be easy in future to add support for other m1 "standard" types to classifier conversion. Typically for ejb-client jars (not sure what the correct classifier is)

Show
nicolas de loof added a comment - - edited The attached patch must be applied on archiva-repository-layer it also require to :
  • rename \src\test\repositories\legacy-repository\org.apache.maven\javadocs to javadoc.jars (in conformance to maven 1 javadoc plugin)
  • move \src\test\repositories\legacy-repository\org.apache.maven\jars\testing-1.0-sources.jar to \src\test\repositories\legacy-repository\org.apache.maven\java-sources (in conformance to maven 1 source plugin).
Those two changes where not handled by my patch tool, as configured to binary types. The idea of the patch is :
  • remove the assertion that legacy path have no classifier. Simply have no way to support unstandard classifiers.
  • automatically use "-javadoc" and "-sources" classifiers for path with types "javadoc.jars" and "java-sources". Check for the classifier to be detected in the version string and remove it.
The patch contains
  • modified code base
  • updated test cases. Thanks to Joakim, this part has good test coverage and new tests are easy to add.
This will be easy in future to add support for other m1 "standard" types to classifier conversion. Typically for ejb-client jars (not sure what the correct classifier is)
Hide
Maria Odea Ching added a comment -

Patch applied (-r596620). Thanks Nicolas!

Show
Maria Odea Ching added a comment - Patch applied (-r596620). Thanks Nicolas!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: