Summary of my issue: in a multi-module project, one of the module has a dependency to another module. When building an uber jar of this module with the maven-shade-plugin
, all its dependencies are correctly included, but not the dependencies of the other module.
I have a multi-module project, with following architecture:
pom.xml (parent pom)
--module_1
----pom.xml
--module_2
----pom.xml
module_2
has a dependency to module_1
, declared in its pom.xml:
<groupId>${project.groupId}</groupId>
<artifactId>module_1</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
I want to build an uber jar of module_2
, and I use the maven-shade-plugin
, with the following declaration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
This results in an uber jar:
- including all dependencies of
module_2
- including the jar of
module_1
- not including dependencies of
module_1
Is there a way to specify to include all dependencies of module_1
as well?
A solution I found is to use the maven-shade-plugin
to buid an uber jar of module_1
as well. As this jar is included in the uber jar of module_2
, then it works. But I'd like to avoid this solution, to be able to release a simple jar file of module_1
, not including its dependencies.
And I want to use the maven-shade-plugin
rather than the maven-assembly-plugin
(for its better control over files included in final jar)
Following request for more details by @user2321368
maven version: Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
module_1's pom.xml where I include its dependencies: (scopes and versions are declared in the parent pom in the dependency management section)
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>other_module_I_havent_mention</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>other_module_I_havent_mention</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
...
</dependencies>