File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven jar plugin: Include 3rdparty packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven jar plugin: Include 3rdparty packages" Watch "Maven jar plugin: Include 3rdparty packages" New topic
Author

Maven jar plugin: Include 3rdparty packages

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
I'm trying to migrate a project from Ant over to Maven. While building the application in a jar-file I need to include some 3rd party libraries.

Trying with the following Maven Jar Plugin configuration, but it doesn't work. Only the content within target/classes are includes.


The Ant jar target has an additional configuration that takes any of these 3rd party dependencies and unpack them and include them in the jar file. I need the Maven Jar Plugin to do the same because we bundle these 3rd party libraries within the application (there are only 3 of them).


I tried to use the Maven Dependency plugin to unpack all my dependencies and place them in the target/classes.However this was not included in the jar file. Wonder if the jar file was created before the dependencies where unpacked. Perhaps I need to change to a different phase for this plugin?
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 255

you shall have to use maven assembly plugin to create runnable jar with dependencies.It takes all the dependencies defined in your pom and then add these in jar file.

Sample build section using assembly plugin is as mentioned below -
http://salilstock.blogspot.in/2012/12/creating-executable-jar-with-dependency.html


Regards
Salil Verma
Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
I was thinking about the assembly plugin. However, using maven-dependency-plugin along with maven-jar-plugin works fine also.
The dependency plugin is run with the goal unpack-dependencies and all dependencies are unpacked into target/classes. Then the jar plugin makes a runnable jar file from the content within target/classes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven jar plugin: Include 3rdparty packages