Skip to content

Commit 03a8cfa

Browse files
committed
scoverage#171 Migrate ScoverageRunner from Groovy to Kotlin
1 parent dca7361 commit 03a8cfa

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

src/main/groovy/org/scoverage/ScoverageRunner.groovy

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.scoverage
2+
3+
import groovy.lang.Closure
4+
import org.gradle.api.file.FileCollection
5+
import org.gradle.api.tasks.Classpath
6+
import java.net.URL
7+
import java.net.URLClassLoader
8+
9+
class ScoverageRunner(@Classpath val runtimeClasspath: FileCollection) {
10+
11+
fun run(action: Closure<*>) {
12+
13+
val cloader = Thread.currentThread().getContextClassLoader() as URLClassLoader
14+
15+
val method = URLClassLoader::class.java.getDeclaredMethod("addURL", URL::class.java)
16+
method.isAccessible = true
17+
18+
runtimeClasspath.files.forEach { f ->
19+
val url = f.toURI().toURL()
20+
if (!cloader.urLs.contains(url)) {
21+
method.invoke(cloader, url)
22+
}
23+
}
24+
25+
action.call()
26+
}
27+
}

0 commit comments

Comments
 (0)