Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-2635

DefaultArtifactCollector.recurse can lose versionRange

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0.7
    • None
    • Linux
    • Patch

    Description

      This affects maven 2.0.4 and 2.0.5 (at least).

      I'm not quite sure how to reproduce the bug in a simple test case, but we have a setup where running the command:
      mvn install site source:jar
      crashes in ArtifactUtils.copyArtifact because artifact.getVersionRange() returns null.
      The code that seems to be causing the problem is in DefaultArtifactCollector.recurse(). Because the Artifact sets the version in setVersionRange, but can't set the VersionRange from setVersion, the VersionRange should take precedence if it exists. A simple diff follows:

      Index: components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
      ===================================================================
      — components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (revision 467177)
      +++ components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java (working copy)
      @@ -114,8 +114,13 @@

      fireEvent( ResolutionListener.MANAGE_ARTIFACT, listeners, node, artifact );

      • if ( artifact.getVersion() != null )
        + VersionRange range = artifact.getVersionRange();
        + if (range != null) { + node.getArtifact().setVersionRange(range); + }

        + else if ( artifact.getVersion() != null )
        +

        { node.getArtifact().setVersion( artifact.getVersion() ); }

        if ( artifact.getScope() != null )

      Attachments

        1. artifact_patch
          1.0 kB
          Bud Osterberg

        Issue Links

          Activity

            People

              brianf Brian E Fox
              bud.osterberg Bud Osterberg
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: