• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

maven create jar with dependencies (Eclipse plugin)

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I wanted to export a project from Eclipse with the Maven plugin with The project has several dependencies, one from my workspace, and several fom e.g. Apache. The export took place, the .jar file was created. I added the main file entry to manifest.mf manually.
When i tried to run the jar, i got an error message:


How can i export a jar fle with the dependencies?
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to use the Assembly plugin to create a JAR file that includes all of the dependencies needed to run. In your assembly descriptor, mention 'jar' as a desired output format.
http://maven.apache.org/plugins/maven-assembly-plugin/index.html
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are looking for the assembly plugin. It exports the dependencies in addition to your jar. It doesn't place the dependencies inside the jar though. Instead it creates a file you can unzip that has all the dependencies.
 
Zoltaan Szabo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I checked out the plugin from the Apache repository, built it, put it to the Eclipse plugins folder, restarted Eclipse. Then i tried to Run as / Maven build... for my project with single goal. But i got an error:
I think it was a naive way what i have done.
Since then i have downloaded maven-assembly-plugin-2.4.jar, put it to the Eclipse plugins folder, restarted Eclipse, but it did not recognise the single goal.
What is the correct way to use (install?) this plugin?
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using a mojo as a goal, you must supply the plugin name also. In other words:

mvn assembly:single

That way Maven knows that you want to run a mojo. If you don't specify a plugin, then Maven assumes you are referencing a build lifecycle phase, and there is no such phase as 'single'.

By the way, I usually include a lifecycle goal for the assembly plugin in the build section, usually associating it with the 'package' phase. They I can use "mvn package" to run the assembly plugin.
reply
    Bookmark Topic Watch Topic
  • New Topic