• 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

Creating an independent and runnable jar for deplyment.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently attempting to learn maven build tool.
I made an example project which have a dependency and a transitive dependency.
Then i want to create/build/install a jar file (uber-jar) which should be able to run independently.
My search has lead me to Apache Maven Shade Plugin
I attempted this Apache Maven Shade Plugin - Executable JAR but for some reason it didn't work.

Here is my pom file.


For the sake of completeness, here is the example project's source code

I also want advice on how to be better with maven and be able to debug maven issues properly, I have attempted to study Maven by Example, what else do you recommend?
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't find an edit button.

So, consider this as a part of the main topic.

What i mean by "didn't work" is this

 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your problem is here:

There is no Main-Class tage, it's mainClass.  I'm not sure you need the manifestEntries tags either.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Toni Lane wrote:I can't find an edit button.


There basically isn't one.  It's too easy for spammers to edit their posts.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I also want advice on how to be better with maven and be able to debug maven issues properly,


You can use the -X or --debug flags when executing mvn on the command line.  If you use the Eclipse IDE, I can give you instructions for how to do that too.
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:

I also want advice on how to be better with maven and be able to debug maven issues properly,


You can use the -X or --debug flags when executing mvn on the command line.  If you use the Eclipse IDE, I can give you instructions for how to do that too.


I'm using IntelliJ Idea (Ultimate if that matters).
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
forgot the "-jar". After adding it, still doesn't work.
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:Your problem is here:

There is no Main-Class tage, it's mainClass.  I'm not sure you need the manifestEntries tags either.


For some reason, i didnt see that post earlier.
Anyway, I removed/commented the manifestEntries and added the mainClass. Still, didn't work.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded you project so I could gool with it.  I don't know exactly why, but your dependencies section was causing the problem.

Just for comparison, here's how I created an executable jar with dependencies on a project of mine.

You can see the whole project here.
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm
Interesting, I ran it without the relocations part and it worked. and jar contained all the dependencies (as well as the transitive dependencies) by default.
 
Toni Lane
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem solved.
The problem was in the relocations part.
Difference is here.
Difference between the working version and the non working version of the pom file at line 64
reply
    Bookmark Topic Watch Topic
  • New Topic