Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating with Maven two separate jars, without dependencies and with ONLY dependencies

Tags:

java

maven

Can Maven create two jars specified in one pom.xml: one jar with my app but without dependencies, and second jar ONLY with dependencies? I'd like to have two separate jars, but I want to run jar with my app and this app has to 'see' all dependencies in second jar. Everything I want to have in one eclipse project, only in result of one run of mvn:package I'd like to create separate jars...Is it possible? Now I use maven-jar-plugin to create jar with app, where I specify the classpath by add line in configuration of maven-jar-plugin:

<addClasspath>true</addClasspath>

Before I have used maven-assebly-plugin to create jar-with-dependencies, but now I have to create separate jar-s....

Thanks in advance, seishin

like image 410
pandominox Avatar asked Mar 17 '11 10:03

pandominox


1 Answers

Here's how I'd do it:

  • use dependency:unpack to unpack all dependencies to a common folder,
  • use the assembly plugin to create a new JAR from the unpacked dependencies
  • provide a custom manifest to your project's jar that links to the dependency jar
like image 73
Sean Patrick Floyd Avatar answered Oct 08 '22 15:10

Sean Patrick Floyd