Reputation: 5979
In my project's pom.xml I have the following dependency:
<dependency>
<groupId>com.my.library</groupId>
<artifactId>MyLib</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
<dependency>
...
</dependency>
I would like to have my project's final built jar including the classes of above com.my.library:MyLib
dependency, so I used maven-shade-plugin in the following way:
<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>
<configuration>
<filters>
<filter>
<artifact>com.my.library:MyLib</artifact>
<includes>
<include>com/my/library/**</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Then, I run mvn clean install
, my project was built successfully.
But when I check the content of MyProject.jar under target/
directory, it doesn't contain classes from com.my.library:MyLib
dependency ,why? Where am I wrong with maven-shade-plugin ?
Upvotes: 3
Views: 4680
Reputation: 32597
Define an <artifactSet>
:
<artifactSet>
<includes>
<include>com.my.library:MyLib</include>
</includes>
</artifactSet>
And try removing the <artifact/>
from the <filters/>
. This should do it.
Upvotes: 1
Reputation: 240870
change pattern to
<includes>
<include>com/my/library/**.class</include>
</includes>
Upvotes: 0