Maven update dependency versions by groupId

41 Views Asked by At

I have a multi-module maven project.

MyProject
├── ModuleA
│   ├── ...
│   └── pom.xml
├── ModuleB
│   ├── ...
│   └── pom.xml
├── ...
└── pom.xml

I want to specify a groupId (com.myCompany.myProject), and find and update the dependencies that fall into that groupId in all modules (something similar to npm outdated and npm update by scope in JS/NPM world).

Also, I prefer to run these commands using CLI (instead of hardcoding in pom.xml) because the groupId will be determined by a script dynamically.

How can I achieve this with maven?

2

There are 2 best solutions below

0
J Fabian Meier On

Something like

versions:use-latest-versions -Dincludes=com.myCompany.myProject:*:*:*:*

?

0
Yu Jiaao On

You increment the minor version like this:

mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 versions:commit

or with fixed number of version:

mvn  build-helper:parse-version versions:set -DnewVersion=1.13.7.15 versions:commit