Maven
  1. Maven
  2. MNG-2653

using ${version} for subproject dependencies doesn't work (maven uses 2.4.1 version instead)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      win xp, maven 2.0.1, eclipse plugin 0.0.3, eclipse 3.1

      Description

      My project is a ear multiproject. It has 5 modules, that have internal dependencies. For example web module needs app and type modules.

      I usually use following declaration for this kind of dependencies. Note that I'm using $

      {version} in dependency. In result I'm requesting foo-type jar of the same version as current project.

      <project>
      <modelVersion>4.0.0</modelVersion>
      <parent>
      <groupId>foo</groupId>
      <artifactId>foo</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      </parent>
      <artifactId>foo-app</artifactId>

      <dependencies>
      <dependency>
      <groupId>foo</groupId>
      <artifactId>foo-type</artifactId>
      <version>${version}

      </version>
      </dependency>
      </dependencies>
      </project>

      This works from commandline, but doesn't work in eclipse plugin. I get following message:

      "Unable to download the artifact from any repository foo:foo-type-2.4.1.jar"

      Maven (or maven plugin) tries to download foo-type module in very strange version (instead 0.0.1-SNAPSHOT)!

      I've attached simple multimodule project.

      1. mngeclipse20-trigger.jpg
        13 kB
        Daniel Schulz
      2. mvn-multiproject.zip
        14 kB
        Michal Stochmialek
      3. org.maven.ide.eclipse-MNGECLIPSE-20-patch.txt
        8 kB
        Daniel Schulz

        Issue Links

          Activity

          Hide
          Eugene Kuleshov added a comment -

          Jason, this is happening with 2.0.2 embedder. The strange thing that execute install from the embedder is working fine, but readProjectWithDependencies() is pulling off version "2.4.1" out of nowhere.

          Show
          Eugene Kuleshov added a comment - Jason, this is happening with 2.0.2 embedder. The strange thing that execute install from the embedder is working fine, but readProjectWithDependencies() is pulling off version "2.4.1" out of nowhere.
          Hide
          Eugene Kuleshov added a comment -

          Same problem with embedder 2.0.3

          Show
          Eugene Kuleshov added a comment - Same problem with embedder 2.0.3
          Hide
          Jozef Kotlár added a comment -

          With version 0.0.7 (e.g. embedder 2.0.4) there seems to be used correct versions in provided sample project.

          Show
          Jozef Kotlár added a comment - With version 0.0.7 (e.g. embedder 2.0.4) there seems to be used correct versions in provided sample project.
          Hide
          Eugene Kuleshov added a comment -

          Veified against trunk version. Probably been working in earlier versions too.

          Show
          Eugene Kuleshov added a comment - Veified against trunk version. Probably been working in earlier versions too.
          Hide
          Daniel Schulz added a comment -

          quick explanation:

          i found the reason for the "$

          {pom.version} > 2.4.1" problem. there is a system property of name "version" set to "2.4.1" in your eclipse jvm (see [Eclipse]>Help->About Eclipse Platform->Configuration Details).

          more detailed explanation:

          Some eclipse plugin or component (no names please) set it. it does'nt matter if you set pom.version, project.version, env.version or a property of name version. if a system property of that name ist set, it beats them all, because the pom variable evaluation order is 1) system properties, 2) project properties and at last 3) pom properties via reflection (see org.apache.maven.project.interpolation.RegexBasedModelInterpolator for Details). Try it by calling "mvn -Dversion=2.4.1 install".

          possible quick fix:

          I fixed the problem by adding an overloaded RegexBasedModelInterpolator-Implementation to my copy of m2eclipse, that filters out the system property "version" and gets version from POM. (Patch file added).

          possible not so quick fix:

          The impl of RegexBasedModelInterpolator should be changed. By using ${pom.version}

          everyone expects, that an evaluator reads out the version property of the POM. I'll look if there is already an issue for that.

          BTW and in the future everyone should use $

          {pom.version}

          . Using $

          {version}

          is dangerous, because it uses a side effect of the RegexBasedModelInterpolator implementation.

          Show
          Daniel Schulz added a comment - quick explanation: i found the reason for the "$ {pom.version} > 2.4.1" problem. there is a system property of name "version" set to "2.4.1" in your eclipse jvm (see [Eclipse] >Help->About Eclipse Platform->Configuration Details). more detailed explanation: Some eclipse plugin or component (no names please) set it. it does'nt matter if you set pom.version, project.version, env.version or a property of name version. if a system property of that name ist set, it beats them all, because the pom variable evaluation order is 1) system properties, 2) project properties and at last 3) pom properties via reflection (see org.apache.maven.project.interpolation.RegexBasedModelInterpolator for Details). Try it by calling "mvn -Dversion=2.4.1 install". possible quick fix: I fixed the problem by adding an overloaded RegexBasedModelInterpolator-Implementation to my copy of m2eclipse, that filters out the system property "version" and gets version from POM. (Patch file added). possible not so quick fix: The impl of RegexBasedModelInterpolator should be changed. By using ${pom.version} everyone expects, that an evaluator reads out the version property of the POM. I'll look if there is already an issue for that. BTW and in the future everyone should use $ {pom.version} . Using $ {version} is dangerous, because it uses a side effect of the RegexBasedModelInterpolator implementation.
          Hide
          Daniel Schulz added a comment -

          again the quick explanation:

          i found the reason for the "$

          {pom.version}

          is 2.4.1" problem. there is a system property of name "version" set to "2.4.1" in your eclipse jvm (see [Eclipse]>Help>About Eclipse Platform->Configuration Details).

          Show
          Daniel Schulz added a comment - again the quick explanation: i found the reason for the "$ {pom.version} is 2.4.1" problem. there is a system property of name "version" set to "2.4.1" in your eclipse jvm (see [Eclipse] >Help >About Eclipse Platform->Configuration Details).
          Hide
          Daniel Schulz added a comment -

          Patch with changed RegexBasedModelInterpolator impl.

          Show
          Daniel Schulz added a comment - Patch with changed RegexBasedModelInterpolator impl.
          Hide
          Daniel Schulz added a comment -

          problem trigger

          Show
          Daniel Schulz added a comment - problem trigger
          Hide
          Michal Stochmialek added a comment -

          Basing on Daniel's comments the issue should be reopened.

          Show
          Michal Stochmialek added a comment - Basing on Daniel's comments the issue should be reopened.
          Hide
          Eugene Kuleshov added a comment -

          Folks, please report it to the Maven Embedder component. This issue should be fixed in there and not worked around in the plugin.

          Show
          Eugene Kuleshov added a comment - Folks, please report it to the Maven Embedder component. This issue should be fixed in there and not worked around in the plugin.
          Hide
          Nathan Pruett added a comment - - edited

          This should be left as an open issue until it is fixed in Maven Embedder (MNG-2651) and the new version of Maven Embedder is included in the Eclipse plugin.

          Show
          Nathan Pruett added a comment - - edited This should be left as an open issue until it is fixed in Maven Embedder ( MNG-2651 ) and the new version of Maven Embedder is included in the Eclipse plugin.
          Hide
          Kenney Westerhof added a comment -

          I'm tempted to 'close - won't fix'.
          $

          {version}

          is evaluated to either a system prop or a -Dversion=..., so this is expected.

          However, $

          {pom.version}

          should be evaluated to the pom's <version> tag. But that's a different issue alltogether.

          Show
          Kenney Westerhof added a comment - I'm tempted to 'close - won't fix'. $ {version} is evaluated to either a system prop or a -Dversion=..., so this is expected. However, $ {pom.version} should be evaluated to the pom's <version> tag. But that's a different issue alltogether.

            People

            • Assignee:
              kenneyw
              Reporter:
              Michal Stochmialek
            • Votes:
              7 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development