Search code examples
javaparent-pommaven

How to make maven to obtain release parent pom instead of latest?


Having declared the master POM for a project using version ranges resolves to the latest version (containing SNAPSHOT). Any way to make it resolve to release ?

Parent POM declaration inside project :

<parent>
  <groupId>my.company</groupId>
  <artifactId>my-company-pom</artifactId>
  <version>(,2.0.0]</version>
</parent>

Parent POM metadata file

<metadata>
  <groupId>my.company</groupId>
  <artifactId>my-company-pom</artifactId>
  <version>1.0.1</version>
  <versioning>
    <latest>1.3.0-SNAPSHOT</latest>
    <release>1.2.0</release>
    <versions>
      <version>1.0.0</version>
      <version>1.0.1-SNAPSHOT</version>
      <version>1.0.1</version>
      <version>1.1.0</version>
      <version>1.2.0</version>
      <version>1.3.0-SNAPSHOT</version>
    </versions>
    <lastUpdated>xxxxxxxxxxxx</lastUpdated>
  </versioning>
</metadata>

Why Maven resolves parent POM version to 1.3.0-SNAPSHOT instead of 1.2.0 ?


Solution

  • As you can see here, it is a very old, well known and controversy bug in maven for me your best option is not to use version range in your case at all as there is no real valid workaround.