How do I convert the following groovy snippet
URL[] urls = sourceSets.main.runtimeClasspath.files.collect {
it.toURI().toURL()
}
to kotlin-dsl? Particularly the property sourceSets doesn't seem to available and fails to compile.
How do I access the sourceSets in a task?
There is no sourceSet
for the runtimeClasspath
. The classpath
is different to the sourceSet
. But if you are interested in getting e.g. the main-sourceset
of a project with the kotlin-dsl, here is a snippet:
java {
val files: Set<File> = sourceSets["main"].java.srcDirs
println(files)
}
Accessing the sourceSet from a task
task("hello-src-set") {
val files: Set<File> = java.sourceSets["main"].java.srcDirs
println(files)
}