dfdf
dfdf

Reputation: 147

Submodule dependencies with Maven

I have a project structure like:

enter image description here

However, whenever I run mvn clean test -DskipTests from the Project 1 directory, it ends up NOT including the Project 2 module in the Maven reactor even though I've listed it as a dependency in Project 1 as follows:

<dependency>
  <groupId>com.main.sub</groupId>
  <artifactId>project2-artId</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

What could be happening and why isnt the dependency being recognized?

Upvotes: 0

Views: 894

Answers (1)

Daniele
Daniele

Reputation: 2837

From https://maven.apache.org/guides/mini/guide-multiple-modules.html; the reactor "Collects all the available modules to build". (modules of the project that is currently being built)

You need to: create a parent project, with packaging pom; add two modules to this project (one for Project1, one for Project2), and submodules for project1.

Then, when you build the parent project, the build order for all modules are decided by the reactor-

Upvotes: 1

Related Questions