0

I have 3 poms in my projects, 1 for parent and 2 for each of the modules in use.

Each pom currently contains <version>2.1.9.0-SNAPSHOT</version> tag

Is it possible for each of the modules to pull this information form the parent automatically?

James Raitsev
  • 92,517
  • 154
  • 335
  • 470

2 Answers2

1

Use the versions-maven plugin as described here : https://stackoverflow.com/a/5726599/320180

Community
  • 1
  • 1
ndeverge
  • 21,378
  • 4
  • 56
  • 85
1

In a multi-module build only the parent should define the versions of the artifacts except in the parents.

  +-- root (pom.xml)
        +-- mod-1 (pom.xml)
        +-- mod-2 (pom.xml)

So the root pom.xml looks like (excerpt):

   <project...>
    <groupId>project.com.root</groupId>
    <artifactId>project-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    ...

every module (mod-1) pom.xml looks like (excerpt):

   <project...>
     <parent>
       <groupId>project.com.root</groupId>
       <artifactId>project-parent</artifactId>
       <version>1.0-SNAPSHOT</version>
     </parent>

     <artifactId>mod-1</artifactId>

In particular the version should never be mentioned in the childs. The changing of the version number at all should be done via the maven-release-plugin during a release cycle. Sometimes it can happen that you change the groupId in the childs in larger projects with quite large number of modules.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235