My current build.gradle looks like below.
repositories {
flatDir {
dirs 'lib'
}
maven {
mavenCentral()
}
dependencies {
compile "commons-logging:commons-logging:1.0.4",
"org.apache.httpcomponents:httpclient:4.4",
"org.apache.httpcomponents:httpcore:4.4",
"com.fasterxml.jackson.core:jackson-annotations:2.5.1",
"joda-time:joda-time:2.7",
compile files('../lib/abc.jar')
}
jar {
manifest{
attributes ("Version" : project.version, "${parent.manifestSectionName}")
attributes ("Name" : project.name, "${parent.manifestSectionName}")
}
from {
configurations.runtime.filter( {! (it.name =~ /abc.*\.jar/ )}).collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
So as you can see I have removed abc.jar at runtime, but in the same way I want to remove few more jars. In short I want few jars inside of fat jar and needs to exclude few. So how can I achieve it?
The following example may help you. You need to add new configuration - it extends compile by default so it will be available during development but will not be included into resulting jar - as joda in the example below.
apply plugin: 'java'
repositories {
mavenCentral()
}
configurations {
lol
}
dependencies {
compile "commons-logging:commons-logging:1.0.4",
"org.apache.httpcomponents:httpclient:4.4",
"org.apache.httpcomponents:httpcore:4.4",
"com.fasterxml.jackson.core:jackson-annotations:2.5.1"
lol "joda-time:joda-time:2.7"
}
jar {
from {
configurations.runtime.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.