Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven jar plugin: Include 3rdparty packages

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic