1
+ /*
2
+ * Copyright (c) 2022 ForteScarlet <[email protected] >
3
+ *
4
+ * 本文件是 simply-robot (或称 simple-robot 3.x 、simbot 3.x ) 的一部分。
5
+ *
6
+ * simply-robot 是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是(按你的决定)任何以后版都可以。
7
+ *
8
+ * 发布 simply-robot 是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
9
+ *
10
+ * 你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看:
11
+ * https://www.gnu.org/licenses
12
+ * https://www.gnu.org/licenses/gpl-3.0-standalone.html
13
+ * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
14
+ *
15
+ */
16
+
17
+ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
18
+ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
19
+
1
20
/*
2
21
* Copyright (c) 2022-2022 ForteScarlet <[email protected] >
3
22
*
17
36
18
37
19
38
tasks.create(" createChangelog" ) {
20
- group = " build "
39
+ group = " documentation "
21
40
doFirst {
22
41
val realVersion = rootProject.version.toString()
23
42
val version = " v$realVersion "
@@ -26,33 +45,65 @@ tasks.create("createChangelog") {
26
45
val changelogDir = rootProject.file(" .changelog" ).also {
27
46
it.mkdirs()
28
47
}
48
+
49
+ val simbotLoggerKotlin =
50
+ project(" :simbot-logger" ).extensions.getByName<KotlinMultiplatformExtension >(
51
+ " kotlin"
52
+ )
53
+
29
54
val file = File (changelogDir, " $version .md" )
30
55
if (! file.exists()) {
31
56
file.createNewFile()
32
- val autoGenerateText = """
33
- **仓库参考:**
34
-
35
- | **模块** | **repo1.maven** | **search.maven** |
36
- |---------|-----------------|------------------|
37
- ${repoRow(" simbot-api" , " love.forte.simbot" , " simbot-api" , realVersion)}
38
- ${repoRow(" simbot-core" , " love.forte.simbot" , " simbot-core" , realVersion)}
39
- ${repoRow(" simbot-logger" , " love.forte.simbot" , " simbot-logger" , realVersion)}
40
- ${repoRow(" simboot-api" , " love.forte.simbot.boot" , " simboot-api" , realVersion)}
41
- ${repoRow(" simboot-core" , " love.forte.simbot.boot" , " simboot-core" , realVersion)}
42
- ${repoRow(" simboot-core-annotation" , " love.forte.simbot.boot" , " simboot-core-annotation" , realVersion)}
43
- ${
44
- repoRow(
45
- " simboot-core-spring-boot-starter" ,
46
- " love.forte.simbot.boot" ,
47
- " simboot-core-spring-boot-starter" ,
48
- realVersion
49
- )
50
- }
57
+
58
+ val autoGenerateText = buildString {
59
+ appendLine(" **仓库参考:**" ).appendLine()
51
60
61
+ appendLine(" <details>" )
62
+ appendLine(" <summary><b>仓库参考</b></summary>" )
63
+ appendLine()
52
64
65
+ appendLine(" | **模块** | **repo1.maven** | **search.maven** |" )
66
+ appendLine(" |---------|-----------------|------------------|" )
67
+ repoRowMulti(simbotLoggerKotlin, " simbot-logger" , " love.forte.simbot" , " simbot-logger" , realVersion)
68
+ repoRow(" simbot-api" , " love.forte.simbot" , " simbot-api" , realVersion)
69
+ repoRow(" simbot-core" , " love.forte.simbot" , " simbot-core" , realVersion)
70
+ repoRow(" simboot-api" , " love.forte.simbot.boot" , " simboot-api" , realVersion)
71
+ repoRow(" simboot-core" , " love.forte.simbot.boot" , " simboot-core" , realVersion)
72
+ repoRow(" simboot-core-annotation" , " love.forte.simbot.boot" , " simboot-core-annotation" , realVersion)
73
+ repoRow(" simboot-core-spring-boot-starter" , " love.forte.simbot.boot" , " simboot-core-spring-boot-starter" , realVersion)
53
74
54
-
55
- """ .trimIndent()
75
+ appendLine()
76
+ appendLine(" </details>" )
77
+ }
78
+
79
+ // val autoGenerateText0 = """
80
+ // **仓库参考:**
81
+ //
82
+ // | **模块** | **repo1.maven** | **search.maven** |
83
+ // |---------|-----------------|------------------|
84
+ // ${repoRow("simbot-api", "love.forte.simbot", "simbot-api", realVersion)}
85
+ // ${repoRow("simbot-core", "love.forte.simbot", "simbot-core", realVersion)}
86
+ // ${repoRow("simbot-logger-jvm", "love.forte.simbot", "simbot-logger-jvm", realVersion)}
87
+ // ${repoRow("simbot-logger-js", "love.forte.simbot", "simbot-logger-js", realVersion)}
88
+ // ${repoRow("simbot-logger-macosx64", "love.forte.simbot", "simbot-logger-macosx64", realVersion)}
89
+ // ${repoRow("simbot-logger-linuxx64", "love.forte.simbot", "simbot-logger-linuxx64", realVersion)}
90
+ // ${repoRow("simbot-logger-mingwx64", "love.forte.simbot", "simbot-logger-mingwx64", realVersion)}
91
+ // ${repoRow("simboot-api", "love.forte.simbot.boot", "simboot-api", realVersion)}
92
+ // ${repoRow("simboot-core", "love.forte.simbot.boot", "simboot-core", realVersion)}
93
+ // ${repoRow("simboot-core-annotation", "love.forte.simbot.boot", "simboot-core-annotation", realVersion)}
94
+ // ${
95
+ // repoRow(
96
+ // "simboot-core-spring-boot-starter",
97
+ // "love.forte.simbot.boot",
98
+ // "simboot-core-spring-boot-starter",
99
+ // realVersion
100
+ // )
101
+ // }
102
+ //
103
+ //
104
+ //
105
+ //
106
+ // """.trimIndent()
56
107
57
108
58
109
file.writeText(autoGenerateText)
@@ -80,16 +131,72 @@ tasks.create("createChangelog") {
80
131
}
81
132
}
82
133
83
- fun repoRow (moduleName : String , group : String , id : String , version : String ): String {
84
- return " | $moduleName | [$moduleName : v$version ](https://repo1.maven.org/maven2/${
85
- group.replace(
86
- " ." ,
87
- " /"
88
- )
89
- } /${
90
- id.replace(
91
- " ." ,
92
- " /"
93
- )
94
- } /$version ) | [$moduleName : v$version ](https://search.maven.org/artifact/$group /$id /$version /jar) |"
134
+ // fun repoRow(moduleName: String, group: String, id: String, version: String): String {
135
+ // return "| $moduleName | [$moduleName: v$version](https://repo1.maven.org/maven2/${
136
+ // group.replace(
137
+ // ".",
138
+ // "/"
139
+ // )
140
+ // }/${
141
+ // id.replace(
142
+ // ".",
143
+ // "/"
144
+ // )
145
+ // }/$version) | [$moduleName: v$version](https://search.maven.org/artifact/$group/$id/$version/jar) |"
146
+ // }
147
+ //
148
+ // fun repoRowMulti(
149
+ // kotlin: KotlinMultiplatformExtension,
150
+ // moduleName: String,
151
+ // group: String,
152
+ // id: String,
153
+ // version: String,
154
+ // ): String {
155
+ // kotlin.targets.forEach {
156
+ // println("simbot-logger target: $it")
157
+ // }
158
+ //
159
+ // return repoRow(moduleName, group, id, version)
160
+ // }
161
+
162
+
163
+ fun StringBuilder.repoRow (moduleName : String , group : String , id : String , version : String ) {
164
+ append(" | " ).append(moduleName).append(" | [" ).append(moduleName).append(" : v" ).append(version)
165
+ append(" ](https://repo1.maven.org/maven2/" )
166
+ append(group.replace(" ." , " /" ))
167
+ append(' /' )
168
+ append(id.replace(" ." , " /" ))
169
+ append(' /' )
170
+ append(version)
171
+ append(" ) | [" )
172
+ append(moduleName).append(" : v" ).append(version)
173
+ append(" ](https://search.maven.org/artifact/" )
174
+ append(group).append(" /" ).append(id).append(" /" ).append(version).append(" /jar) |" )
175
+ appendLine()
176
+ // "| $moduleName | [$moduleName: v$version](https://repo1.maven.org/maven2/${
177
+ // group.replace(
178
+ // ".",
179
+ // "/"
180
+ // )
181
+ // }/${
182
+ // id.replace(
183
+ // ".",
184
+ // "/"
185
+ // )
186
+ // }/$version) | [$moduleName: v$version](https://search.maven.org/artifact/$group/$id/$version/jar) |"
187
+ }
188
+
189
+ fun StringBuilder.repoRowMulti (
190
+ kotlin : KotlinMultiplatformExtension ,
191
+ moduleName : String ,
192
+ group : String ,
193
+ id : String ,
194
+ version : String ,
195
+ ) {
196
+ kotlin.targets.forEach {
197
+ if (it.platformType != KotlinPlatformType .common) {
198
+ repoRow(" $moduleName -${it.targetName} " , group, " $id -${it.targetName.toLowerCase()} " , version)
199
+ }
200
+ }
201
+
95
202
}
0 commit comments