Hello All,
I have this lines of working groovy code and I would like to convert it to kotlin
ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antClasspath.each { File jar ->
println "Adding to ant classpath : " + jar.absolutePath
println(antClassLoader.getClass().getName()) //output: org.gradle.internal.classloader.VisitableURLClassLoader
antClassLoader.addURL(jar.toURI().toURL())
}
The antClassLoader is from type VisitableURLClassLoader everything is OK
val antClassLoader: ClassLoader = org.apache.tools.ant.Project::class.java.classLoader
configurations["antClasspath"].forEach { jar: File ->
logger.log(LogLevel.LIFECYCLE, "Adding to ant classpath : " + jar.absolutePath)
antClassLoader.addURL(jar.toURI().toURL()) //does not compile because type is ClassLoader
}
Any ideas?
Tom