如何转换以下 groovy 代码段
URL[] urls = sourceSets.main.runtimeClasspath.files.collect {
it.toURI().toURL()
}
到kotlin-dsl?特别是属性 sourceSets 似乎不可用并且无法编译。
如何访问任务中的源集?
如何转换以下 groovy 代码段
URL[] urls = sourceSets.main.runtimeClasspath.files.collect {
it.toURI().toURL()
}
到kotlin-dsl?特别是属性 sourceSets 似乎不可用并且无法编译。
如何访问任务中的源集?
没有。sourceSet
_ runtimeClasspath
与classpath
不同sourceSet
。但是,如果您有兴趣获得例如main-sourceset
带有 kotlin-dsl 的项目,这里有一个片段:
java {
val files: Set<File> = sourceSets["main"].java.srcDirs
println(files)
}
从任务访问 sourceSet
task("hello-src-set") {
val files: Set<File> = java.sourceSets["main"].java.srcDirs
println(files)
}