forked from komapper/komapper-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
66 lines (61 loc) · 2.35 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
plugins {
base
}
val kotlinVersion: String by project
val kspVersion: String by project
val komapperVersion: String by project
val encoding: String by project
val branchName: String = "v" + komapperVersion.replace(Regex("(\\d+\\.\\d+)(\\.\\d+)(-.+)?"), "$1$3")
fun replaceVersion(version: String, prefix :String, suffix: String = "\"") {
ant.withGroovyBuilder {
"replaceregexp"("match" to """($prefix)[^"]*($suffix)""",
"replace" to "\\1${version}\\2",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to "content") {
"include"("name" to "en/docs/Quickstart/_index.md")
"include"("name" to "ja/docs/Quickstart/_index.md")
"include"("name" to "en/docs/Reference/annotation-processing.md")
"include"("name" to "ja/docs/Reference/annotation-processing.md")
"include"("name" to "en/docs/Reference/gradle-plugin.md")
"include"("name" to "ja/docs/Reference/gradle-plugin.md")
}
}
}
}
fun changeConfig(key :String, old: String, new: String) {
ant.withGroovyBuilder {
"replaceregexp"("match" to "^$key = $old #can_be_replaced_with_gradle$",
"replace" to "$key = $new #can_be_replaced_with_gradle",
"encoding" to encoding,
"flags" to "gm") {
"fileset"("dir" to ".") {
"include"("name" to "config.toml")
}
}
}
}
tasks {
register("updateVersion") {
doLast {
replaceVersion(kotlinVersion, """kotlin\("jvm"\) version """")
replaceVersion("$kotlinVersion-$kspVersion", """id\("com.google.devtools.ksp"\) version """")
replaceVersion(komapperVersion, """val komapperVersion = """")
replaceVersion(komapperVersion, """id\("org.komapper.gradle"\) version """")
changeConfig("version", "\".*\"", "\"$branchName\"")
changeConfig("github_branch", "\".*\"", "\"$branchName\"")
}
}
register("archive") {
doLast {
changeConfig("archived_version", "false", "true")
changeConfig("algolia_docsearch", "true", "false")
changeConfig("offlineSearch", "false", "true")
}
}
register("debug") {
doLast {
println("branchName: $branchName")
}
}
}