I’m trying to unzip/copy some files from a single dependency.jar
.
Now trying to achieve the same with a kotlin build script yields a java.lang.IllegalStateException: Expected configuration 'myExtraDepedency' to contain exactly one file, however, it contains more than one file.
When I debug into the script I can see that myExtraDependency.files()
contains all depedencies of my project. Perhaps I have a misconception of what myExtraDependency.files()
should contain but I expected it to only contain my single somedependency.jar
.
val myExtraDependencyby configurations.creating
dependencies {
myExtraDependency("com.acme:somedependency:1.0.0")
}
val unzipMyExtraDependency by tasks.creating(Copy::class) {
group = "unzip"
from(zipTree(myExtraDependency.singleFile))
include("/interesting_files/**")
into("$projectDir/build/tmp/")
}
Here is my workaround for now. I would appreciate if you could explain what I’m doing wrong. Thank you very much in advance.
val unzipMyExtraDependency by tasks.creating(Copy::class) {
group = "unzip"
val somedependencyJar = myExtraDependency.files().find { it.name.contains("somedependency") }
from(zipTree(somedependencyJar !!))
include("/interesting_files/**")
into("$projectDir/build/tmp/")
}