Gradle Kotlin DSL:从依赖项中提取内容
Gradle Kotlin DSL: Extract contents from dependency
如何将以下代码片段(基于 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/"
}
我没有使用过 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/")
}
}
如何将以下代码片段(基于 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/"
}
我没有使用过 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/")
}
}