0

For our project, we have a dependency on another internal library and this library has very very frequent releases. In the parent application, we want to always use the latest version of this dependency. With Maven 3.x, I did the following in the pom file

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions-maven-plugin.version}</version>
                <configuration>
                    <includes>
                        <include>abc.def.xyz:exmaple-dep</include>
                    </includes>
                </configuration>
            </plugin>

But when I use the maven to fetch the latest versions, it is fetching latest versions of all dependencies. I tested this behaviour with the below command:

mvn versions:display-dependency-updates -Dincludes=abc.def.xyz:exmaple-dep

What would be the solution that versions-maven-plugin fetches the latest version only of the given dependency.

Nitesh
  • 193
  • 1
  • 2
  • 17
  • And this does not solve your problem? https://stackoverflow.com/questions/30571/how-do-i-tell-maven-to-use-the-latest-version-of-a-dependency – aksappy Jul 31 '20 at 13:49

1 Answers1

1

The goal versions:display-dependency-updates does not have an include parameter, but versions:use-latest-versions has.

If the syntax does not work, use abc.def.xyz:exmaple-dep:*:*:* instead.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thanks you, indeed it works. Do you also know if I can include this 'update' in the compilation itself, so 'mvn clean compile' should do this? Otherwise, I would have to run the command 'manually' which can cause inconsistencies for deveopers. – Nitesh Aug 03 '20 at 10:25
  • No, it needs to be a separate run. Maven picks up the dependencies at the very beginning, so that changing them would not have any effect on the current run. – J Fabian Meier Aug 03 '20 at 10:35
  • Thanks, it seems to work, I integrated in a script in Jenkins pipeline. Do you know, if it is possible to use the same plugin to bump the version of an artifact before deploying it in maven repository. We have a project which is continuously updated and our team is manually incrementing the version each time before merging the code, this ofcourse results in conflicts and slows down the team – Nitesh Aug 07 '20 at 10:40