![]() |
BX Land
Home to all things Bruce Grant
|
|
![]() |
Author: Bruce Grant, Jr. (BX)
Published: February 24, 2010
Building a Jar and Including Classes from Dependencies using Maven
I finally figured out how to build a jar file using Maven that will include the class files from dependent jars in the resulting jar I build.
There's a Maven plugin named shade that will include all the classes from all dependent jar files by default. Here's my pom.xml file that makes it happen. 1<project xmlns="http://maven.apache.org/POM/4.0.0"
2xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
4 http://maven.apache.org/maven-v4_0_0.xsd">
5 <modelVersion>4.0.0</modelVersion>
6 <groupId>mygroupname</groupId>
7 <artifactId>myartifactname</artifactId>
8 <version>1.0</version>
9
10 <properties>
11 <final.jar.name>myjarfilename</final.jar.name>
12 </properties>
13
14 <build>
15 <plugins>
16 <plugin>
17 <groupId>org.apache.maven.plugins</groupId>
18 <artifactId>maven-shade-plugin</artifactId>
19 <version>1.3.1</version>
20 <executions>
21 <execution>
22 <phase>package</phase>
23 <goals>
24 <goal>shade</goal>
25 </goals>
26 <configuration>
27 <finalName>${final.jar.name}</finalName>
28 <artifactSet>
29 <excludes>
30 <exclude>server.policy</exclude>
31 </excludes>
32 </artifactSet>
33 </configuration>
34 </execution>
35 </executions>
36 </plugin>
37 </plugins>
38 </build>
39</project> Comments
Be the first to add a comment.
Add a Comment
|
|























