1

I have all these version numbers throughout parent pom and children poms including the parent reference like so

  <parent>
     <groupId>com.cigna.ifp</groupId>
     <artifactId>ifp-core</artifactId>
     <version>${parent.version}</version>
  </parent>

and dependency references to other child projects like so

<dependency>
  <groupId>com.cigna.ifp</groupId>
  <artifactId>ifp-shared</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

and finally the declaration of the version of the thing we are building

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company</groupId>
  <artifactId>artifcat</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>ifp-shared</name>
  <url>http://maven.apache.org</url>

EDIT based on some answers which solved half the question...

We want to have all the versions be ${project.version} since it is really just one project with one release number.

I can seem to do ${project.version} in the dependency but this does not work in the parent xml code above. Is there another way? (man, I should really just switch to gradle).

thanks, Dean

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212

4 Answers4

1
<parent>
 <groupId>com.cigna.ifp</groupId>
 <artifactId>ifp-core</artifactId>
 <version>1.2.3-SNAPSHOT</version> <!-- real version-->
</parent>

<artifactId>blah</artifactId>
<!-- No version here, will be inherited -->

<dependency>
  <groupId>com.cigna.ifp</groupId>
  <artifactId>ifp-shared</artifactId>
  <version>${project.version}</version>
</dependency>
ptyx
  • 4,074
  • 1
  • 19
  • 21
  • I don't want to type 1.2.3-SNAPSHOT in my 5 child projects...how do I avoid doing that? – Dean Hiller Jun 11 '12 at 15:45
  • Unfortunately, not that I know. The idea is that a project is self contained, so you need a version somewhere in the pom. Aka you *could* build with a parent version and parent obtained from a public repo, and different from the one in your filesystem right now. Not that you'd ever want to do that, but that's the way maven works right now. – ptyx Jun 11 '12 at 15:52
  • Btw, in your child projects, both version and groupId are inherited from parent by default and can be left out. Also you can work around the ${project.version} in dependencies by using dependencyManagement in parent - but I'm not sure I'd recommend that in all cases. – ptyx Jun 11 '12 at 15:53
0

project.version is what you want. Not parent.version.

Andrew T Finnell
  • 13,417
  • 3
  • 33
  • 49
0

You need to use dependencyManagement tag to centerilize the versions in the parent pom for the dependencies.

See this question and answers

differences between dependencymanagement and dependencies in maven

For you your own modules, some of the properties are inherited from the parent pom. You will need to declare the parent version in each child but you don't need to declare a groupId/version in your child poms if you want them to be same as their parent's.

Community
  • 1
  • 1
fmucar
  • 14,361
  • 2
  • 45
  • 50
0

We switched to gradle which works fabulously now. Every automated build a new version is released as 1.2.x where x is the next build number. Downstream, projects depend on 1.2.+. This allows every release to be official so QA can test it, reject it or go, yup, build 1.2.568 is the release we will release to the world. Projects can depend on 1.2. but then they don't get bug fixes. This seems to work much better than all that snapshot nonsense as you give QA a snapshot and they approve and you have to change and do another build. We want every build to look official so they can release the one that happens to pass all QA tests.

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212