Reputation: 34688
I have a task that looks like this (this is not the main jar this module kicks out, there is another one I can't show)
task interfaceJar(type: Jar) {
classifier = 'interface'
from "$buildDir/classes/main/"
include 'x/y/z/stuff.class'
}
And some dependencies like this
dependencies {
/* lots of dependencies */
compile 'com.esotericsoftware:kryo:3.0.3'
}
How can I include that one specific dependency in my interfaceJar task?
Upvotes: 1
Views: 848
Reputation: 23647
To include dependency jar without unpacking it first: (Note: if you use this, you may want to add a Class-Path entry to your manifest)
task interfaceJar(type: Jar) {
classifier = 'interface'
from "$buildDir/classes/main/"
from configurations.compile.findAll{it.name.contains('kryo')}
include 'x/y/z/stuff.class'
include '*.jar'
}
Edit: to unpack your dependency jar and include the contents in your interface jar:
task interfaceJar(type: Jar) {
classifier = 'interface'
from("$buildDir/classes/main/"){
include 'stuff.class'
}
configurations.compile.findAll{it.name.contains('kryo')}.each{
from(it.isDirectory() ? it : zipTree(it))
}
}
Upvotes: 2