How do I make a runnable jar with gradle that depends on three jars?
I have a Java program with a simple main class that depends on the a.jar, b.jar, c.jar libraries. How do I make it so that I can create an executable jar with all these jars packaged correctly?
I know in the bank problem you need to include:
apply plugin: 'java'
apply plugin:'application'
repositories {
mavenCentral()
}
jar {
manifest {
attributes 'Main-Class': 'com.foo.bar.MainClass'
}
}
But not sure what to do with the 3 external banks my code is using.
+3
source to share
1 answer
The easiest way is to bundle the dependency bans into the main Jar:
jar {
from "path/to/jar1", "path/to/jar2"
}
Or, if the boxes are checked out from a Maven / Ivy repository:
jar {
from configurations.runtime
}
Alternatively you can use a plugin like gradle-onejar which covers more use cases.
+2
source to share