Fix getOutputForTask for newer Gradle versions
This commit is contained in:
+4
-11
@@ -386,18 +386,11 @@ abstract class BaseGradleIT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.getOutputForTask(taskName: String): String {
|
fun CompiledProject.getOutputForTask(taskName: String): String {
|
||||||
fun String.substringAfter(delimiter: String, missingDelimiterValue: () -> String): String {
|
val taskOutputRegex = ("\\[LIFECYCLE] \\[class org\\.gradle(?:\\.internal\\.buildevents)?\\.TaskExecutionLogger] :$taskName" +
|
||||||
val index = indexOf(delimiter)
|
"([\\s\\S]+?)" +
|
||||||
return if (index == -1) missingDelimiterValue() else substring(index + delimiter.length, length)
|
"Finished executing task ':$taskName'").toRegex()
|
||||||
}
|
|
||||||
|
|
||||||
fun String.substringBefore(delimiter: String, missingDelimiterValue: () -> String): String {
|
return taskOutputRegex.find(output)?.run { groupValues[1] } ?: error("Cannot find output for task $taskName")
|
||||||
val index = indexOf(delimiter)
|
|
||||||
return if (index == -1) missingDelimiterValue() else substring(0, index)
|
|
||||||
}
|
|
||||||
|
|
||||||
return output.substringAfter("[LIFECYCLE] [class org.gradle.TaskExecutionLogger] :$taskName") { error("Can't find start for task $taskName") }
|
|
||||||
.substringBefore("Finished executing task ':$taskName'") { error("Can't find completion for task $taskName") }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertCompiledKotlinSources(
|
fun CompiledProject.assertCompiledKotlinSources(
|
||||||
|
|||||||
Reference in New Issue
Block a user