【发布时间】:2021-08-17 15:24:01
【问题描述】:
我有一个脚本可以在生成的源代码中找到必要的行时打印,但我也必须删除这些行,我想知道我该怎么做? 此任务似乎适用于 groovy,但仅打印 Kotlin 的找到值。
tasks.register<Copy>("filter") {
from("src/generate-swagger/java") {
filter { line ->
if (line.contains("com.magazine.report.exception")) {
println("found import")
return@filter null
}
if (line.contains("throw new ReportException")) {
println("found exception")
return@filter line.replace("throw new ReportException", "throw new RuntimeException")
}
return@filter line
}
}
into("generated/java")
dependsOn("generate")
}
【问题讨论】:
标签: gradle build.gradle gradle-kotlin-dsl