When I run the following command for the root
project, it checks for updates of ALL dependencies:
mvn versions:use-latest-versions
I want to limit versions update for only those dependencies which are reachable from the root
:
root/pom.xml
├── A/pom.xml
│ └── D/pom.xml
│ └── E/pom.xml
├── B/pom.xml
└── C/pom.xml
├── F/pom.xml
└── G/pom.xml
The group and artifact ids of these dependencies are in the current reactor build (multi-module build).
For example, I don not want to update external dependencies like junit
or commons-logging
.
There is an option excludeReactor. And I need an opposite like includeOnlyReactor.
Otherwise, it is unreliable and tedious work to specify all possible artifact patterns "owned" by your project via includes option.
Set module dependencies version to ${project.version}
Good practice is to do it in dependencyMnaagement section of root pom.
Example:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0.0</version>
<modules>
<module>A</module>
<module>B</module>
<module>C</module>
</modules
<dependencyManagement>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>B</artifactId>
<version>${project.version}</version>
</dependency>
...And so on....
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>G</artifactId>
<version>${project.version}</version>
</dependency>
</dependencyManagement>
</project>
Then whenever you want to use the module in another module (e.g. module G in B) you put just
<dependency>
<groupId>com.mycompany.app</groupId>
<artifactId>B</artifactId>
</dependency>
To change version of the project use mvn versions:set
. This will keep all the modules in the same version and the dependency management section will keep the dependencies in the same version as well.
Obviously it won't work if you want to keep your modules in same version all the time. But this will be more tricky anyway.