-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
47 lines (38 loc) · 1.44 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
@file:Suppress("UnstableApiUsage")
import kotlin.text.replace
tasks.maybeCreate<Delete>("clean").apply {
delete(layout.buildDirectory)
}
val publishLocally by tasks.registering {
/* Update version used in samples */
val sampleSettings = fileTree("samples") {
include("**/settings.gradle.kts")
}.files
val version = project.version.toString()
inputs.property("version", version)
val fireworkVersion = deps.versions.firework.get()
inputs.property("fireworkVersion", fireworkVersion)
doLast {
logger.quiet("Found: $sampleSettings")
sampleSettings.forEach { settingsFile ->
val text = settingsFile.readText()
val declaration = """id("org.jetbrains.compose-hot-reload") version"""
val newText = text.lines().map { line ->
if (declaration !in line) return@map line
val indent = line.substringBefore(declaration)
indent + declaration + " \"${version}\""
}.joinToString("\n") { line ->
val fireworkVersionRegex = Regex(""""2.*-firework\..*"""")
line.replace(fireworkVersionRegex, "\"$fireworkVersion\"")
}
if(newText != text) {
settingsFile.writeText(newText)
}
}
}
}
subprojects {
publishLocally.configure {
this.dependsOn(tasks.named { name -> name == "publishAllPublicationsToLocalRepository" })
}
}