In have one child module testA
that has a dependency on vaadin-client-compiler that depends on commons-lang3 version 3.1, it also depends on another child module testB
which depends on commons-lang3 version 3.4.
I expect testA
to use the 3.4 version because testB
depends on it but it uses the 3.1 version. I can solve it by adding []
to the version in testB
project but why does it happen? Why maven doesn't resolve the correct version without being forced?
MCVE:
Parent:
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<packaging>pom</packaging>
<modules>
<module>testB</module>
<module>testA</module>
</modules>
</project>
Child that depends
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<version>7.6.8</version>
<artifactId>vaadin-client-compiler</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>testB</groupId>
<artifactId>testB</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<groupId>testA</groupId>
<artifactId>testA</artifactId>
</project>
And the dependent child
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>testB</groupId>
<artifactId>testB</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
</dependencies>
</project>