4

I cloned the git repository of Apache ActiveMQ Artemis project (https://github.com/apache/activemq-artemis) and then typed

mvn -Ptests test -pl :integration-tests

I was surprised to see log messages like the following

...
Downloading: http://repository.apache.org/snapshots/org/apache/activemq/artemis-selector/1.4.0-SNAPSHOT/artemis-selector-1.4.0-20160625.030221-11.jar
Downloading: http://repository.apache.org/snapshots/org/apache/activemq/artemis-core-client/1.4.0-SNAPSHOT/artemis-core-client-1.4.0-20160625.030211-11.jar
...

Since e.g. artemis-core-client is contained in the git repository I cloned in the beginning, I'd have expected maven just builds it from there.

That way, when I make changes in the core client source, they get picked up by the integration tests.

Instead, maven is downloading the jar from the repository.

Question: How do I configure maven to always build all modules that are in the git repository and download only "true" dependencies, which I mean things not in the git repository?

user7610
  • 25,267
  • 15
  • 124
  • 150
  • 2
    Essentially, this is the same as this question: http://stackoverflow.com/questions/33131880/maven-multi-module-project-cannot-find-sibling-module You should run Maven from root project and not directly inside a module. This is because the dependencies haven't been installed so Maven tries to download them. – Tunaki Jun 26 '16 at 12:14
  • @Tunaki So the "-pl :integration-tests" is what's causing maven to download, instead of compile. Right? Because I am running mvn in the directory where is the main project .pom file. – user7610 Jun 26 '16 at 12:18
  • No, there is no integration-tests module in the main project, check my answer. You are executing maven on the test/main project, not the library/main project. – A_Di-Matteo Jun 26 '16 at 12:18

1 Answers1

3

You are not executing the Maven build on the main project, on the main pom.xml which indeed defines the artemis-selector and artemis-core-client modules, among others.

You are executing the Maven build on the tests and its pom.xml, where only tests modules are defined. This is a side/test project, which has as parent the previous pom file, but it doesn't play any role in its parent modules definition. Hence, dependencies are not resolved as modules but as Maven dependencies.

You should firstly install (via mvn clean install) the former project, so that libraries will be available in your local Maven cache (hence no downloading would be triggered), then execute the tests project.


Check the Maven docs for a inheritance vs aggregation difference to further clarify it.

From the Stack Overflow, the follow threads could also be interesting:

user7610
  • 25,267
  • 15
  • 124
  • 150
A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
  • 1
    "You should firstly install (via mvn clean install) the former project," This seems somewhat error prone, since it is IMO very easy to run the tests against a different set of jars than I wanted to test. Is this the best one can do with Maven, or could the project be configured better? I'll ask a new question if you think it's called for. – user7610 Jun 26 '16 at 12:22
  • @JiriDanek it's the strategy choosen for the project I would say, probably to reduce the number of modules or to have integrations test on a different main project for separation of concerns (no integration tests on modules, to enforce no integration tests on working in progress code?). As a different strategy, the whole tests side project could have been a profile of the main project, adding its modules to the whole build. However, from a comment of the pom, looks like the whole main build could already take more than 2 hours, so probably that has also played a role in this choice. – A_Di-Matteo Jun 26 '16 at 12:24
  • @JiriDanek if that helped you out, please consider [accepting](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) the answer so that the question doesn't show up as unanswered globally. Thanks. – A_Di-Matteo Jun 28 '16 at 11:59
  • 1
    @user7610 a note: you can force maven to redownload the dependencies to be sure to work with the right jars https://stackoverflow.com/questions/7959499/force-re-download-of-release-dependency-using-maven – dcolazin Apr 06 '22 at 08:50