[Build] Fix configuration cache issues (part 1)
* Make `clean` task compatible with configuration cache * Make Java compile instrumentation compatible with configuration cache * Make settings.gradle compatible with configuration cache * Initial work on making IntelliJInstrumentCodeTask compatible with configuration cache * Make writeStdlibVersion task compatible with configuration cache * Copy some properties to not capture it's owning object into lambda to support configuration cache Relates to #KT-44611
This commit is contained in:
@@ -21,22 +21,26 @@ artifacts.add(buildVersion.name, file(buildVersionFilePath)) {
|
||||
builtBy(writeBuildNumber)
|
||||
}
|
||||
|
||||
fun replaceVersion(versionFile: File, versionPattern: String, replacement: (MatchResult) -> String) {
|
||||
check(versionFile.isFile) { "Version file $versionFile is not found" }
|
||||
val text = versionFile.readText()
|
||||
val pattern = Regex(versionPattern)
|
||||
val match = pattern.find(text) ?: error("Version pattern is missing in file $versionFile")
|
||||
val newValue = replacement(match)
|
||||
versionFile.writeText(text.replaceRange(match.groups[1]!!.range, newValue))
|
||||
}
|
||||
|
||||
|
||||
val writeStdlibVersion by tasks.registering {
|
||||
val kotlinVersionLocal = kotlinVersion
|
||||
val versionFile = rootDir.resolve("libraries/stdlib/src/kotlin/util/KotlinVersion.kt")
|
||||
inputs.property("version", kotlinVersion)
|
||||
inputs.property("version", kotlinVersionLocal)
|
||||
outputs.file(versionFile)
|
||||
|
||||
fun replaceVersion(versionFile: File, versionPattern: String, replacement: (MatchResult) -> String) {
|
||||
check(versionFile.isFile) { "Version file $versionFile is not found" }
|
||||
val text = versionFile.readText()
|
||||
val pattern = Regex(versionPattern)
|
||||
val match = pattern.find(text) ?: error("Version pattern is missing in file $versionFile")
|
||||
val newValue = replacement(match)
|
||||
versionFile.writeText(text.replaceRange(match.groups[1]!!.range, newValue))
|
||||
}
|
||||
|
||||
doLast {
|
||||
replaceVersion(versionFile, """fun get\(\): KotlinVersion = KotlinVersion\((\d+, \d+, \d+)\)""") {
|
||||
val (major, minor, _, optPatch) = Regex("""^(\d+)\.(\d+)(\.(\d+))?""").find(kotlinVersion)?.destructured ?: error("Cannot parse current version $kotlinVersion")
|
||||
val (major, minor, _, optPatch) = Regex("""^(\d+)\.(\d+)(\.(\d+))?""").find(kotlinVersionLocal)?.destructured ?: error("Cannot parse current version $kotlinVersionLocal")
|
||||
val newVersion = "$major, $minor, ${optPatch.takeIf { it.isNotEmpty() } ?: "0" }"
|
||||
logger.lifecycle("Writing new standard library version components: $newVersion")
|
||||
newVersion
|
||||
|
||||
@@ -42,7 +42,7 @@ noDefaultJar()
|
||||
|
||||
// dummy is used for rewriting dependencies to the shaded packages in the embeddable compiler
|
||||
compilerDummyJar(compilerDummyForDependenciesRewriting("compilerDummy") {
|
||||
classifier = "dummy"
|
||||
archiveClassifier.set("dummy")
|
||||
})
|
||||
|
||||
class CoreXmlShadingTransformer : Transformer {
|
||||
|
||||
Reference in New Issue
Block a user