What’s the Kotlin equivalent of the Groovy `List&l...
# announcements
z
What’s the Kotlin equivalent of the Groovy
List<T>.join(..)
function?
n
joinToString
?
z
so the function I’m actually converting is:
Copy code
android.bootClasspath.join(File.pathSeparator)
Copy code
android.bootClasspath: List<File>
File.pathSeparator: String
but I think it will do the trick! thanks!
Copy code
task.classpath += objects.fileCollection()
  .from(android.bootClasspath.joinToString(File.pathSeparator))
n
Do you actually want to combine strings
or are you concatenating paths?
z
I have no idea lol
Basically, trying to convert the following into Kotlin
Copy code
TaskProvider<Javadoc> javadocs = tasks.register(javadocsTaskName, Javadoc) {
        excludes = ['**/*.kt']
        source = android.sourceSets.main.java.source
        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
    }
and what I have is:
Copy code
val javadocs = tasks.register(javadocsTaskName, Javadoc::class.java) { task ->
    task.setExcludes(listOf("**/*.kt"))
    val mainSource = android.sourceSets.named("main")
        .map { main -> main.java.sourceFiles }
    task.source = mainSource.get()
    task.classpath += objects.fileCollection()
        .from(android.bootClasspath.joinToString(File.pathSeparator))
}
n
.joinToString(File.pathSeparator)
is almost definitely concatenating paths 😛 but is also a fine way to do it. You could do some kind of
Paths.get(*android.bootClasspath).toString()
thing probably, but eh