I’m probably too confused about Groovy and how the DSL is constructed, but I’m having trouble specifying what I want. The task at hand: Extract the contents of a jar file as resources. (Can’t simply include the jar as a dependency, some files need to be renamed.)
Here’s what I tried (most likely showing that this is my first interaction with both Gradle and Groovy):
sourceSets {
main {
java {
...
}
resources {
zipTree 'path/to/libs/mylib.jar'
}
}
}
which gets ignored.
Then I tried
sourceSets {
main {
java {
...
}
resources {
srcDirs = zipTree 'path/to/libs/mylib.jar'
}
}
}
but that gave me
Could not determine the dependencies of task ':processResources'.
Finally I tried
sourceSets {
main {
java {
...
}
resources {
srcDir zipTree 'path/to/libs/mylib.jar'
}
}
}
which gave me
No such property: path/to/libs/mylib.jar for class: org.gradle.api.internal.file.DefaultSourceDirectorySet
At that point, I decided that trial-and-error configuring might be less effective than asking on the forum…
I tried looking at working_with_files.html, but I’m having trouble applying task-based examples to DSL configuration inside a sourceSet block (due to being new to Gradle and Groove, my understanding of how the DSL works is improving but still a lot more vague than I feel comfortable with). I know I could simply slap a closure on the sourceSets block that reconfigures things, but the approaches that googling gave me would splitting the configuration for a specific resource in two.
Any (pointers to) working examples appreciated. Thanks!