let's say I have a multi module maven project, with 3 modules:
Parent A and children B and C
C has a dependency on B.
Given that my .m2 local repository doesn't contain any of my artifacts (deleted them manually), when I run a build on the parent A module, the first thing maven does is to download the B dependency from Nexus.
I am wondering if there's a way to stop that, I only want maven to build B first and then use that B artifact for building C. I don't want it to download it from nexus when B is going to be built anyway in this very build.
I also don't want to use the -o (offline) option. I am just trying to understand how maven exactly works.
I am guessing that this is related to the fact that both B artifacts have the same snapshot version?
Cheers
Edit: This only happens once, the first time I run a build. If I run it one more time, B already exists in my m2 directory so it's not fetched again. I am just wondering why B is downloaded the very first time
Edit2: This is an example of the first lines of me building the parent pom.xml with
mvn clean install -DskipTests
[INFO] Scanning for projects...
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/org/androidannotations/androidannotations/3.3-SNAPSHOT/maven-metadata.xml
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/org/androidannotations/androidannotations/3.3-SNAPSHOT/maven-metadata.xml (2 KB at 2.5 KB/sec)
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/org/androidannotations/androidannotations-parent/3.3-SNAPSHOT/maven-metadata.xml
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/org/androidannotations/androidannotations-parent/3.3-SNAPSHOT/maven-metadata.xml (622 B at 1.7 KB/sec)
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/org/androidannotations/androidannotations-api/3.3-SNAPSHOT/maven-metadata.xml
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/org/androidannotations/androidannotations-api/3.3-SNAPSHOT/maven-metadata.xml (2 KB at 4.2 KB/sec)
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/common/0.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/common/0.2-SNAPSHOT/maven-metadata.xml (972 B at 2.6 KB/sec)
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/common/0.2-SNAPSHOT/common-0.2-20150312.211752-3.jar
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/common/0.2-SNAPSHOT/common-0.2-20150312.211752-3-tests.jar
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/common/0.2-SNAPSHOT/common-0.2-20150312.211752-3-tests.jar (49 KB at 31.3 KB/sec)
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/common/0.2-SNAPSHOT/common-0.2-20150312.211752-3.jar (94 KB at 33.9 KB/sec)
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/application/0.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/application/0.2-SNAPSHOT/maven-metadata.xml (938 B at 3.2 KB/sec)
Downloading: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/application/0.2-SNAPSHOT/application-0.2-20150312.203520-2.apk
Downloaded: http://xx.xx.xx:xxxxx/nexus/content/groups/public/com/follower/application/0.2-SNAPSHOT/application-0.2-20150312.203520-2.apk (6585 KB at 63.0 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Follower
[INFO] Follower - Common
[INFO] Follower - Application
[INFO] Follower - Application Espresso Tests
[INFO] Follower - Server
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Follower 0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ follower ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ follower ---
[INFO] Installing C:\Users\sakis\Desktop\intelliJ projects\follower\pom.xml to C:\Users\sakis\.m2\repository\com\follower\follower\0.2-SNAPSHOT\follower-0.2-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Follower - Common 0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ common ---
[INFO] Deleting C:\Users\sakis\Desktop\intelliJ projects\follower\common\target
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\sakis\Desktop\intelliJ projects\follower\common\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ common ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 50 source files to C:\Users\sakis\Desktop\intelliJ projects\follower\common\target\classes
As you can see the "common" module jar, "common" module test-jar and "application.apk" is downloaded, even though these artifacts will get created when the common and application modules are built.
In the pom.xml I have the following (only snippets):
parent pom.xml:
<groupId>com.follower</groupId>
<artifactId>follower</artifactId>
<version>0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>common</module>
<module>application</module>
<module>espresso</module>
<module>server</module>
</modules>
common pom.xml: no dependency on other modules
application pom.xml:
<parent>
<groupId>com.follower</groupId>
<artifactId>follower</artifactId>
<version>0.2-SNAPSHOT</version>
</parent>
<artifactId>application</artifactId>
<packaging>apk</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
</dependencies>
server pom.xml:
<parent>
<groupId>com.follower</groupId>
<artifactId>follower</artifactId>
<version>0.2-SNAPSHOT</version>
</parent>
<artifactId>server</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>common</artifactId>
<type>test-jar</type>
</dependency>
</dependencies>
espresso pom.xml:
<parent>
<groupId>com.follower</groupId>
<artifactId>follower</artifactId>
<version>0.2-SNAPSHOT</version>
</parent>
<artifactId>espresso</artifactId>
<packaging>apk</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>application</artifactId>
<scope>provided</scope>
<type>apk</type>
</dependency>
</dependencies>