3

How to create executable JAR with gradle?

By executable I mean JAR should run and run well, not run and then crash with unresolved dependencies.

Also I need 1-2 Gradle-style line solution, not dozen lines groovy code, collecting dependencies, generated by some unknown plugins.

Also, solution should work out of the box. No any complex configuration applicable.

I have tried plugin: "edu.sc.seis.launch4j" and it didn't work.

Opal
  • 81,889
  • 28
  • 189
  • 210
Dims
  • 47,675
  • 117
  • 331
  • 600
  • your *personal* requirements are irrelevant and vague and *didn't work* are vague, this is **off-topic: recommendations** as well as the duplicate. Just because you don't want to put any effort into the task does not really mean anything other than you don't want to do the work to read the instructions, it does not mean there is a problem to be solved. –  Jun 17 '16 at 14:17
  • Nonsense. I gave not my "personal" requirements, but my personal definition of word "executable". Accepted answer for "duplicated" question is just incorrect: just adding manifest is completely not enough to be able to execute a JAR. The answer is similar to one where would suggested to apply `chmod +x ` to JAR file, because `x` attribute means "executable" – Dims Jun 17 '16 at 15:52
  • this is more *rant* than question as is your last comment, either way it is off-topic for **multiple reasons** and multiple duplicates all equally valid –  Jun 17 '16 at 15:56

1 Answers1

3

Basically there are two possibilities:

  1. Application plugin, provided by gradle. Basically it prepares jar and a handful of scripts to run it.
  2. Shadow plugin which prepares an uberjar, a runnable, repackaged artifact with all the dependencies required.
Opal
  • 81,889
  • 28
  • 189
  • 210