You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Issue to resolve

  • We want to provide a single place for versions to be defined for a multi project build.

Option 1

Using the standard dependencyManagement element to specify the versions.

Possible limitations:

  • Might be that you want to use the version string somewhere else for whatever reason. You could reference the dependency but that would probably be pretty verbose.
<project>
  ...
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.foo</groupId>
        <artifactId>foo</artifactId>
        <version>1.0</version>     
      </dependency>
     <dependency>
        <groupId>org.bar</groupId>
        <artifactId>bar</artifactId>
        <version>2.0</version>     
      </dependency>
    </dependencies>
  </dependencyManagement>
  ...
</project>

Option 2

This option has each version used specified in a property and that property is used in the dependencyManagement element and can be used anywhere else.

Possible limitations:

  • Any tooling made to help manage dependencies would be dealing with free form properties
<project>
  ...
  <properties>
    <fooVersion>1.0</fooVersion>
    <barVersion>2.0</barVersion>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.foo</groupId>
        <artifactId>foo</artifactId>
        <version>${fooVersion}</version>     
      </dependency>
     <dependency>
        <groupId>org.bar</groupId>
        <artifactId>bar</artifactId>
        <version>${barVersion}</version>     
      </dependency>
    </dependencies>
  </dependencyManagement>
  ...
</project>

Option 3

Using the standard dependencyManagement element to specify the versions and generate properties based on the dependency declaration

Possible limitations:

  • might appear as magic that properties are just appearing, but could make a project-info goal to print out available properties
<project>
  ...
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.foo</groupId>
        <artifactId>foo</artifactId>
        <version>1.0</version>     
      </dependency>
     <dependency>
        <groupId>org.bar</groupId>
        <artifactId>bar</artifactId>
        <version>2.0</version>     
      </dependency>
    </dependencies>
  </dependencyManagement>
  ...
</project>
jdcasey

The most EL-neutral syntax for referencing such a built-in property might be something like:

${dependencies["org.foo:foo"].version}

One note on using dependencyManagement information for POM interpolation: depMgmt info is only available when directly referenced by the POM, and the injection of depMgmt information currently takes place after interpolation IIRC. It's just another detail we'll have to deal with in order to enable this.

JIRA reference

  • No labels