No, projects in the reactor will always be preferred over other dependencies.
This hold true even regardless of the following circumstances:
- Running Maven with the
-U
flag set, meaning that update checks are forced.
- Setting the
<updatePolicy>
to always
in either settings.xml
or in the POM.
- Configuring the
install
plugin to <installAtEnd>true</installAtEnd>
Maven will figure out which artifacts are part of your reactor and exclude them from update checks.
This is quite easy to prove. If you try running Maven with either of the configurations above, you will see that Maven won't download artifact A
(for instance), since each download is logged in the console.
For example, let's assume that you have this root POM:
<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>org.example</groupId>
<artifactId>root</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>root</name>
<modules>
<module>A</module>
<module>B</module>
...
<module>Z</module>
</modules>
</project>
And each module looks like this:
<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>org.example</groupId>
<artifactId>root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<name>...</name>
<artifactId>...</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
but the last one looks like this:
<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>org.example</groupId>
<artifactId>root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>Z</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Z</name>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>A</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Then no, module A will never be replaced by another version of the artifact from the repository.