mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
This will help reduce build times when changes are made to the precompiled script plugins used in the build. This is because a change in buildSrc causes the whole project to become out-of-date [0]. Using an included build instead works around this problem. [0] https://docs.gradle.org/7.2/userguide/organizing_gradle_projects.html#sec:build_sources
30 lines
847 B
Kotlin
30 lines
847 B
Kotlin
import org.gradle.api.DefaultTask
|
|
import org.gradle.api.file.RegularFileProperty
|
|
import org.gradle.api.provider.Property
|
|
import org.gradle.api.tasks.Input
|
|
import org.gradle.api.tasks.InputFile
|
|
import org.gradle.api.tasks.TaskAction
|
|
|
|
abstract class UpdateVersionInFileTask : DefaultTask() {
|
|
|
|
@get:InputFile
|
|
abstract val fileToUpdate: RegularFileProperty
|
|
|
|
@get:Input
|
|
abstract val linePartToFind: Property<String>
|
|
|
|
@get:Input
|
|
abstract val lineTransformation: Property<String>
|
|
|
|
@TaskAction
|
|
fun run() {
|
|
val newContent = fileToUpdate.asFile.get().readLines()
|
|
.joinToString(LN) { if (it.contains(linePartToFind.get())) lineTransformation.get() else it }
|
|
fileToUpdate.asFile.get().writeText("$newContent$LN")
|
|
}
|
|
|
|
companion object {
|
|
val LN: String = System.lineSeparator()
|
|
}
|
|
}
|