简体   繁体   中英

Maven build dependencies before checking nexus

I am building my multi module project using the command

mvn clean deploy -DskipTests

This project has 3 maven modules: A, B, C.

A doesn't depend on anything.

B doesn't depend on anything.

C depends on A.

I am getting a very weird scenario where maven sees that C depends on A and then instead of building A from the sources it decides to check nexus for it (as my .m2 local repository doesn't contain A) and it fetches an old version of A. Then it goes on building everything, but when it reaches C it uses that old version of A and fails.

If I run my build in offline mode then it works great, but the problem is that I do want to deploy my new artifacts in nexus when I am done, and maven offline mode restricts me from doing that.

I am wondering if I am doing something really weird, this seems like a pretty easy to handle scenario.

Edit: If I login to nexus and i manually delete all the old artifacts and then build with the command provided above, everything works fine.

Edit 2: C depends on A with a "provided" scope, something like :

 <dependency>
     <groupId>com.test</groupId>
     <artifactId>application</artifactId>
     <scope>provided</scope>
     <type>jar</type>
 </dependency>

(version is declared in dependencyManagement section of the parent pom).

Options:

  1. Commit A so that you get the latest changes and C builds fine

  2. Make C depend on a specific version of A. Update the version of A and make C depend on it

Turns out the problem was related to the Espresso Testing framework in android. One of the android dependencies in the pom.xml was set with <scope>test</scope> instead of <scope>provided</scope> and that was causing the trouble described.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM