[Gradle] Fix init script for coroutines
Use doFirst instead of beforeTask to add javaagent args for coroutines debugging.
This commit is contained in:
committed by
Alexander Likhachev
parent
2bb7f6a168
commit
11b92bc597
+14
-10
@@ -27,16 +27,20 @@ class KotlinGradleCoroutineDebugProjectResolver : AbstractProjectResolverExtensi
|
|||||||
val script =
|
val script =
|
||||||
//language=Gradle
|
//language=Gradle
|
||||||
"""
|
"""
|
||||||
gradle.taskGraph.beforeTask { Task task ->
|
gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
|
||||||
if (task instanceof Test || task instanceof JavaExec) {
|
taskGraph.allTasks.each { Task task ->
|
||||||
def kotlinxCoroutinesCoreJar = task.classpath.find { it.name.startsWith("kotlinx-coroutines-core") }
|
if (task instanceof Test || task instanceof JavaExec) {
|
||||||
if (kotlinxCoroutinesCoreJar) {
|
task.doFirst { Task forkedTask ->
|
||||||
def results = (kotlinxCoroutinesCoreJar.getName() =~ /kotlinx-coroutines-core(\-jvm)?-(\d[\w\.\-]+)\.jar${'$'}/).findAll()
|
def kotlinxCoroutinesCoreJar = forkedTask.classpath.find { it.name.startsWith("kotlinx-coroutines-core") }
|
||||||
if (results) {
|
if (kotlinxCoroutinesCoreJar) {
|
||||||
def version = results.first()[2]
|
def results = (kotlinxCoroutinesCoreJar.getName() =~ /kotlinx-coroutines-core(\-jvm)?-(\d[\w\.\-]+)\.jar${'$'}/).findAll()
|
||||||
def referenceVersion = org.gradle.util.VersionNumber.parse('1.3.7-255')
|
if (results) {
|
||||||
if (org.gradle.util.VersionNumber.parse(version) > referenceVersion) {
|
def version = results.first()[2]
|
||||||
task.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesCoreJar?.absolutePath}", "-ea")
|
def referenceVersion = org.gradle.util.VersionNumber.parse('1.3.7-255')
|
||||||
|
if (org.gradle.util.VersionNumber.parse(version) > referenceVersion) {
|
||||||
|
forkedTask.jvmArgs ("-javaagent:${'$'}{kotlinxCoroutinesCoreJar?.absolutePath}", "-ea")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user