I\'m trying to set up a multi-module Maven project, and the inter-module dependencies are apparently not being set up correctly.
I have:
In a Maven module structure like this:
- parent
- child1
- child2
You will have in the parent
pom
this:
<modules>
<module>child1</module>
<module>child2</module>
</modules>
If you now depend on child1
in child2
by putting the following in your <dependencies>
in child2
:
<dependency>
<groupId>example</groupId>
<artifactId>child1</artifactId>
</dependency>
You will receive an error that the JAR for child1
cannot be found. This can be solved by declaring a <dependencyManagement>
block including child1
in the pom
for parent
:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>example</groupId>
<artifactId>child1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
child1
will now be build when you run a compile
or package
etc. goal on parent
, and child2
will find child1
's compiled files.
Realizing this is an older thread but it seems that either the tool evolved or this might have been missed the first time around.
It is possible to perform a build that makes dependencies resolved without installing by doing a reactor build.
If you start your build in the parent that describes the module structure of your project then your dependencies between your modules will be resolved during the build itself through the internal Maven reactor.
Of course this is not the perfect solution since it does not solve the build of a single individual module within the structure. In this case Maven will not have the dependencies in his reactor and will bee looking to resolve it in the repository. So for individual builds you still have to install the dependencies first.
Here is some reference describing this situation.