brain storm
brain storm

Reputation: 31272

how to automatically update maven dependencies in a multi-level project?

At my workplace, different groups works on providing different services. My team consumes these services. Currently, whenever a new version of Service is rolled out, we manually change the pom.xml to the latest version of dependency and then make a build. I am wondering if there is an automatic way of pulling latest release into build.

Here is an example to explain:

pom.xml


    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

        <groupId>com.company.product</groupId>
        <artifactId>User-Application</artifactId>
        <version>1.0.1-SNAPSHOT</version>
        <packaging>war</packaging>

<properties>
      <Service1-version>1.0.2</Service-1>
       <Service2-version>1.1.2</Service-2>
       <Service3-version>2.0.2</Service-3>
</properties>

    <dependencies>

            <dependency>
                <groupId>com.company.product</groupId>
                <artifactId>Service1</artifactId>
                <version>${Service1-version}</version>
            </dependency>

            <dependency>
                <groupId>com.company.product</groupId>
                <artifactId>Service2</artifactId>
                <version>${Service2-version}</version>
            </dependency>

            <dependency>
                <groupId>com.company.product</groupId>
                <artifactId>Service3</artifactId>
                <version>${Service3-version}</version>
            </dependency>

    .....
    ....

    </project>

When new release of each service is made, we manually change the pom.xml to get the latest dependency. How can this be managed automatically?

Upvotes: 3

Views: 6748

Answers (1)

mszalbach
mszalbach

Reputation: 11470

The versions-maven-plugin should be able to do this with the task versions:update-properties. See an example here.

Upvotes: 4

Related Questions