5

When using Maven with a multi-module project like:

/pom.xml
/project-a/pom.xml
/project-b/pom.xml

If the root POM builds both modules A and B, and B depends on A, when I'm running a mvn package and I run the build from the root POM:

Q: Does the build for B pull from the current build "reactor" to locate the dependency for A? (ie. the changes in A that are being built) Or does it always go to the local repository?

Basically I'm trying to figure out if I need to be running mvn install when there are changes in A that B depends on, or whether I can just run mvn package to save some time.

Craig Otis
  • 31,257
  • 32
  • 136
  • 234
  • 2
    If you run it from the root via `mvn clean package` or maybe `mvn clean verify` the dependencies will be resolved within the reactor. This means in consequence that you never need to do `mvn clean install`. If you ever face the situation that you need to do `mvn clean install` on a multi module build that means that your dependencies within the modules are not correct. And no it will not go to the remote repository for modules which are contained in the reactor... – khmarbaise Mar 30 '19 at 18:22

1 Answers1

3

If you run it from the root via mvn clean package or maybe mvn clean verify (If you have integration tests) the dependencies will be resolved within the reactor.

This means in consequence that you never need to do mvn clean install. If you ever face the situation that you need to do mvn clean install on a multi module build that means that your dependencies within the modules are not correct.

And no it will not go to the remote repository for modules which are contained in the reactor.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • Thank you! It was very hard to find any reference to this behavior in the Maven docs. – Craig Otis Mar 30 '19 at 19:06
  • @CraigOtis Can you make a suggestion where to put such information or at best would be to open an issue on https://github.com/apache/maven-site/issues ? and fabulous would be to create pull request for the documentation on the page you think it belongs... – khmarbaise Mar 30 '19 at 19:40
  • Perhaps on the multi-module page? https://maven.apache.org/guides/mini/guide-multiple-modules.html That's where I remember looking. – Craig Otis Apr 01 '19 at 11:19