0

I am tired of having to manually change the dependency version for every repository and run the build and tests.

Are there any good solutions/tools out there to centralize this, so that you only have to change the version in one file? A requirement is that you still can override the desired version from the local repository.

Easypete
  • 11
  • 3

1 Answers1

0

In my Maven projects i use a parent pom for dependency management. I use the "dependencyManagement" tag in parent pom for declare al available dependencies and his versions for child modoules.

DIRECTORY HERARCHY

- project-name
   - module-A
       - pom.xml
   - pom.xml

In parent pom.xml I specify the depencyManagement tag:

<dependencyManagement>
   <dependencies>
     <dependency>
        <groupId>com.test</groupId>
        <artifactId>artifact</artifactId>
        <version>1.0</version>
      </dependency>
   </dependencies>
</dependencyManagement>

In module-A pom.xml there is something like:

<parent>
    <artifactId>module-A</artifactId>
    <groupId>com.test</groupId>
    <version>1.0</version>
  </parent>

<dependencies>
<!-- The version is inherited from parent pom -->
         <dependency>
            <groupId>com.test</groupId>
            <artifactId>artifact</artifactId>
          </dependency>
    </dependencies>

This way permits change the version of dependencies only in parent pom.xml. Al child modules will use it.

You can find more details in Maven's official documentation: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

JosemyAB
  • 387
  • 3
  • 9