This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
262 lines (199 loc) · 9.16 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.6.10"
kotlin("plugin.serialization") version "1.6.10"
id("org.jetbrains.compose") version "1.1.1"
}
group = "love.forte.simbot"
val subVersion = "0.10"
version = "3.$subVersion"
repositories {
mavenCentral()
google()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
configurations.all {
resolutionStrategy {
cacheChangingModulesFor(1, "seconds")
}
}
val simbot = "3.0.0.preview.17.0"
val simbotMirai = "3.0.0.0.preview.11.0"
dependencies {
implementation(kotlin("stdlib"))
// selenium https://www.selenium.dev/zh-cn/documentation/webdriver/getting_started/open_browser/
implementation("org.seleniumhq.selenium:selenium-java:4.1.2")
// https://www.selenium.dev/zh-cn/documentation/webdriver/getting_started/install_drivers/
// https://github.com/bonigarcia/webdrivermanager
// https://bonigarcia.dev/webdrivermanager/
implementation("io.github.bonigarcia:webdrivermanager:5.0.3")
// https://testerhome.com/topics/19895
// https://stackoverflow.com/questions/25431380/capturing-browser-logs-with-selenium-webdriver-using-java
// https://github.com/lightbody/browsermob-proxy#using-with-selenium
implementation("net.lightbody.bmp:browsermob-core:2.1.5")
// https://github.com/lightbody/browsermob-proxy/blob/master/mitm/README.md
// implementation("org.littleshoot:littleproxy:1.1.2")
// implementation("net.lightbody.bmp:mitm:2.1.5")
// qrcode
implementation("com.google.zxing:core:3.4.1")
implementation("com.google.zxing:javase:3.4.1")
// simbot3-mirai
implementation("love.forte.simbot.component:simbot-component-mirai-core:$simbotMirai")
implementation("love.forte.simbot:simbot-core:$simbot")
// log4j2
implementation("org.apache.logging.log4j:log4j-api:2.17.1")
implementation("org.apache.logging.log4j:log4j-core:2.17.1")
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1")
//testImplementation(kotlin("test"))
//implementation(compose.desktop.common)
implementation(compose.desktop.currentOs)
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "11"
javaParameters = true
// -opt-in=kotlin.RequiresOptIn
// -Xopt-in=kotlin.RequiresOptIn
freeCompilerArgs = freeCompilerArgs + listOf("-Xopt-in=kotlin.RequiresOptIn")
}
}
compose.desktop {
application {
mainClass = "love.forte.simbot.mlh.MainKt"
jvmArgs += listOf(
"-XX:ErrorFile=.log/hs_err.log",
"-XX:-HeapDumpOnOutOfMemoryError",
"-XX:HeapDumpPath=.log/dump.hprof",
)
nativeDistributions {
targetFormats(
TargetFormat.Rpm,
TargetFormat.Deb,
//TargetFormat.Pkg,
TargetFormat.Dmg,
TargetFormat.Msi,
TargetFormat.Exe,
)
// outputBaseDir
modules("java.naming")
licenseFile.set(project.file("_COPYING.MERGE"))
// description = "simbot下用于进行mirai登录验证的辅助工具"
packageName = "simbotMiraiLoginHelper"
packageVersion = project.version.toString()
copyright = "(C) 2022 ForteScarlet. All rights reserved."
macOS {
iconFile.set(project.file("icon.icns"))
}
windows {
iconFile.set(project.file("icon.ico"))
shortcut = true
menuGroup = "simbot"
}
linux {
iconFile.set(project.file("icon.png"))
shortcut = true
debMaintainer = "ForteScarlet@163.com"
menuGroup = "simbot"
}
}
}
}
tasks.register("packageAndMove") {
group = "compose desktop"
dependsOn("package", ) // "createDistributable"
doLast("packageAndMoveDoLast") {
val nativeDistributions = compose.desktop.application.nativeDistributions
val outputBaseDir = nativeDistributions.outputBaseDir
val outputMain = outputBaseDir.dir("main").orNull
?: throw NullPointerException("No outputDir: $outputBaseDir/main")
val newOutputDir = outputMain.dir("distributions")
newOutputDir.asFile.mkdirs()
println("outputMain: $outputMain")
nativeDistributions.targetFormats
.forEach { targetOsExtension ->
val targetOsExtensionName = targetOsExtension.name.toLowerCase()
val currentFile = outputMain.files(targetOsExtensionName)
.asFileTree
.filter { it.extension == targetOsExtensionName }
.firstOrNull()
?.takeIf { it.exists() }
?: return@forEach
// 应该就只有一个
val packageName = nativeDistributions.packageName
val packageVersion = nativeDistributions.packageVersion ?: project.version
val os = when (targetOsExtension) {
TargetFormat.Deb -> "linux"
TargetFormat.Rpm -> "linux"
TargetFormat.Dmg -> "macOS"
TargetFormat.Pkg -> "macOS"
TargetFormat.Exe -> "windows"
TargetFormat.Msi -> "windows"
else -> "unknown"
}
val newFileName = "$packageName-$os-$packageVersion.$targetOsExtensionName"
val newFile = newOutputDir.file(newFileName).asFile
newFile.createNewFile()
currentFile.copyTo(target = newFile, overwrite = true)
// val zipFileExtra = when (os) {
// "macOS", "windows" -> "zip"
// else -> "tar"
// }
//
// val newZipFileName = "$packageName-$os-$packageVersion.$zipFileExtra"
// val zipFile = newOutputDir.file(newZipFileName).asFile
// val fileOutputStream = FileOutputStream(zipFile)
// // copy App and zip?
// val zipOut = ZipOutputStream(fileOutputStream)
// GZIPOutputStream(fileOutputStream)
}
/*
Deb
Dmg
Exe
*/
}
}
tasks.create("createChangelog") {
group = "build"
doFirst {
val version = "v${project.version}"
println("Generate change log for $version ...")
// configurations.runtimeClasspath
val changelogDir = project.file(".changelog").also {
it.mkdirs()
}
val file = File(changelogDir, "$version.md")
if (!file.exists()) {
file.createNewFile()
val autoGenerateText = """
real version: `v0.$subVersion`
simbot-mirai version: `v$simbotMirai`
## 其他说明
#### 版本号
目前版本 `v3.$subVersion` 等同于 `v0.$subVersion`, 请在脑海中自动将版本最前的数字-3。
由于 `macOS`(`dmg` & `pkg`) 打包必须保证版本号符合规则: `MAJOR[.MINOR][.PATCH]` 且:
- `MAJOR` 是大于0的数字;
- `MINOR` 是一个可选的非负整数;
- `PATCH` 是一个可选的非负整数;
因此对于`dmg`和`pkg`文件来说,不能使用最大版本号小于0的版本。因此选择将 `MAJOR` 数字与当前环境下 `simbot` 对应的 `MAJOR` 一致,也就是 `3`。
有关于其他文件的版本说明请参考 [compose-jb/tutorials/Building native distribution/Specifying package version](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#specifying-package-version)
<hr>
## 安装下载
从 [release](https://github.com/simple-robot/simbot-mirai-login-helper/releases/tag/v$version) 下 `Assets` 中所需安装包并下载安装。
#### 简单指引
- [linux(deb)](https://github.com/simple-robot/simbot-mirai-login-helper/releases/download/v$version/simbotMiraiLoginHelper-linux-$version.deb)
- [linux(rpm)](https://github.com/simple-robot/simbot-mirai-login-helper/releases/download/v$version/simbotMiraiLoginHelper-linux-$version.rpm)
- [macOS](https://github.com/simple-robot/simbot-mirai-login-helper/releases/download/v$version/simbotMiraiLoginHelper-macOS-$version.dmg)
- [windows(exe)](https://github.com/simple-robot/simbot-mirai-login-helper/releases/download/v$version/simbotMiraiLoginHelper-windows-$version.exe)
- [windows(msi)](https://github.com/simple-robot/simbot-mirai-login-helper/releases/download/v$version/simbotMiraiLoginHelper-windows-$version.msi)
""".trimIndent()
file.writeText(autoGenerateText)
}
}
}