如何将以下代码段(基于Peter Niederwieser的代码段)转换为Kotlin?
configurations {
assets
}
dependencies {
assets 'somegroup:someArtifact:someVersion'
}
task extractApi(type: Sync) {
dependsOn configurations.assets
from { // use of closure defers evaluation until execution time
configurations.assets.collect { zipTree(it) }
}
into "$buildDir/assets/"
}
答案 0 :(得分:1)
我没有Kotlin DSL的经验,但是显然extractApi
任务可以重写为
val assets by configurations.creating
dependencies {
assets("somegroup", "someArtifact", "someVersion")
}
tasks {
val extractApi by creating(Sync::class) {
dependsOn(assets)
from(assets.map {
zipTree(it)
})
into("$buildDir/api/")
}
}