Created
March 3, 2015 05:57
-
-
Save martinandersson/c63675ce87947da1ef4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'java-library-distribution' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'org.apache.commons:commons-lang3:3.3.2' | |
} | |
// Task "distZip" added by plugin "java-library-distribution": | |
distZip.shouldRunAfter(build) | |
jar { | |
// Keep jar clean: | |
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF' | |
manifest { | |
attributes 'Main-Class': 'com.somepackage.MainClass', | |
'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ') | |
} | |
// How-to add class path: | |
// http://stackoverflow.com/questions/22659463/add-classpath-in-manifest-using-gradle | |
// https://gist.github.com/simon04/6865179 | |
} |
If you use gradle 3.0 and the io.spring.gradle:dependency-management-plugin, you must delay setting the Class-Path like this:
afterEvaluate {
jar {
manifest {
attributes (
'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ')
)
}
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A textual preview of the results can be found here.