mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-07-01 12:57:24 +00:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
3932db11a1
|
|||
d18c059498
|
|||
e6b581b8cd
|
|||
26d7443c87
|
|||
2bf4eb684e
|
|||
5251b62733
|
|||
3ec5a8e9c3
|
|||
62f6c08cd2
|
|||
5e6f64f056
|
|||
a036695330
|
|||
e9c975f5c5
|
|||
9aac42d414
|
|||
5add6d9909
|
|||
eee6b7d2c9
|
|||
ff396425a7
|
|||
580d9122e5
|
|||
2a607f1129
|
|||
2d6da7c1ae
|
|||
6235c5f51a
|
|||
255a02c93c
|
|||
dce28be9c7
|
|||
673c6d8392
|
|||
d586ca378e
|
|||
3ba4364a07
|
|||
eda0e522cd
|
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
**/
|
||||||
|
!scalabot-app/build/install/
|
1
.github/workflows/build-and-test.yml
vendored
1
.github/workflows/build-and-test.yml
vendored
@ -25,6 +25,7 @@ jobs:
|
|||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt-hotspot'
|
distribution: 'adopt-hotspot'
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
- name: Grant execute permission for gradlew
|
- name: Grant execute permission for gradlew
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
- name: Build and test
|
- name: Build and test
|
||||||
|
65
.github/workflows/create-release.yml
vendored
Normal file
65
.github/workflows/create-release.yml
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
name: Create release draft
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v[0-9]+.[0-9]+.[0-9]+*'
|
||||||
|
|
||||||
|
# 该 Action 有以下步骤:
|
||||||
|
# 1. 拉取并构建代码, 然后生成 Application 发行包;
|
||||||
|
# 2. 创建 Release, 并标记为 Draft(草稿);
|
||||||
|
# 3. 上传 Application 发行包;
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
timeout-minutes: 10
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# 创建更新日志.
|
||||||
|
- name: 'Get Previous tag'
|
||||||
|
id: previous-tag
|
||||||
|
uses: younited/get-previous-tag-action@v1.0.0
|
||||||
|
with:
|
||||||
|
match: "v*.*.*"
|
||||||
|
- name: Set up Python 3
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
- name: Install Commitizen
|
||||||
|
run: pip install -U commitizen
|
||||||
|
- name: Create Change log
|
||||||
|
run: cz ch --start-rev ${{ steps.previous-tag.outputs.previous-tag }} --file-name ${{ github.workspace }}/CURRENT_CHANGELOG.md
|
||||||
|
|
||||||
|
# 开始构建项目.
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt-hotspot'
|
||||||
|
cache: 'gradle'
|
||||||
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
- name: Build and test
|
||||||
|
uses: gradle/gradle-build-action@v2.2.1
|
||||||
|
with:
|
||||||
|
gradle-version: 'wrapper'
|
||||||
|
arguments: clean test assembleDist
|
||||||
|
|
||||||
|
# 创建新的发行版本
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
body_path: ${{ github.workspace }}/CURRENT_CHANGELOG.md
|
||||||
|
files: |
|
||||||
|
*/build/distributions/*
|
||||||
|
*/build/libs/*
|
10
.github/workflows/gradle-wrapper-validation.yml
vendored
10
.github/workflows/gradle-wrapper-validation.yml
vendored
@ -1,10 +0,0 @@
|
|||||||
name: "Validate Gradle Wrapper"
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
validation:
|
|
||||||
name: "Validation"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: gradle/wrapper-validation-action@v1
|
|
49
.github/workflows/release-container-image.yml
vendored
Normal file
49
.github/workflows/release-container-image.yml
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
name: Release container image
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: lamgc/scalabot
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt-hotspot'
|
||||||
|
cache: 'gradle'
|
||||||
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
- name: Build and test
|
||||||
|
uses: gradle/gradle-build-action@v2.2.1
|
||||||
|
with:
|
||||||
|
gradle-version: 'wrapper'
|
||||||
|
arguments: clean test installDist
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker BuildX
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push container image
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ env.IMAGE_NAME }}:latest, ${{ env.IMAGE_NAME }}:${{ github.ref_name }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
49
.github/workflows/release-dev-container-image.yml
vendored
Normal file
49
.github/workflows/release-dev-container-image.yml
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
name: Build development version container image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "main"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
timeout-minutes: 15
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'adopt-hotspot'
|
||||||
|
cache: 'gradle'
|
||||||
|
- uses: gradle/wrapper-validation-action@v1
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
- name: Build project and install Distribution package
|
||||||
|
uses: gradle/gradle-build-action@v2.2.1
|
||||||
|
with:
|
||||||
|
gradle-version: 'wrapper'
|
||||||
|
arguments: installDist
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker BuildX
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push container image
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: lamgc/scalabot:dev
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
FROM openjdk:18
|
||||||
|
|
||||||
|
ENV BOT_DATA_PATH /scalabot/data/
|
||||||
|
WORKDIR /scalabot/run/
|
||||||
|
|
||||||
|
CMD ["/scalabot/app/bin/scalabot-app"]
|
||||||
|
|
||||||
|
COPY scalabot-app/build/install/scalabot-app/ /scalabot/app/
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.6.10" apply false
|
kotlin("jvm") version "1.7.10" apply false
|
||||||
id("org.jetbrains.kotlinx.kover") version "0.5.1" apply false
|
id("org.jetbrains.kotlinx.kover") version "0.5.1" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12,5 +12,5 @@ allprojects {
|
|||||||
|
|
||||||
}
|
}
|
||||||
group = "net.lamgc"
|
group = "net.lamgc"
|
||||||
version = "0.5.0"
|
version = "0.5.1"
|
||||||
}
|
}
|
@ -56,3 +56,8 @@ application {
|
|||||||
tasks.jar.configure {
|
tasks.jar.configure {
|
||||||
exclude("**/logback-test.xml")
|
exclude("**/logback-test.xml")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
|
}
|
||||||
|
@ -18,6 +18,8 @@ import java.net.URL
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
import java.util.function.Supplier
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
private val log = KotlinLogging.logger { }
|
private val log = KotlinLogging.logger { }
|
||||||
|
|
||||||
@ -102,9 +104,9 @@ private fun createDefaultRepositoryId(): String {
|
|||||||
* 必须提供 `pathSupplier` 或 `fileSupplier` 其中一个, 才能正常提供路径.
|
* 必须提供 `pathSupplier` 或 `fileSupplier` 其中一个, 才能正常提供路径.
|
||||||
*/
|
*/
|
||||||
internal enum class AppPaths(
|
internal enum class AppPaths(
|
||||||
private val pathSupplier: () -> String = { fileSupplier.invoke().canonicalPath },
|
private val pathSupplier: PathSupplier,
|
||||||
private val initializer: AppPaths.() -> Unit = AppPaths::defaultInitializer,
|
private val initializer: AppPaths.() -> Unit = AppPaths::defaultInitializer,
|
||||||
private val fileSupplier: () -> File = { File(pathSupplier()) }
|
private val fileSupplier: FileSupplier,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* 数据根目录.
|
* 数据根目录.
|
||||||
@ -113,7 +115,7 @@ internal enum class AppPaths(
|
|||||||
*
|
*
|
||||||
* 提示: 结尾不带 `/`.
|
* 提示: 结尾不带 `/`.
|
||||||
*/
|
*/
|
||||||
DATA_ROOT(fileSupplier = {
|
DATA_ROOT(fileSupplier = FileSupplier {
|
||||||
File(
|
File(
|
||||||
System.getProperty(PathConst.PROP_DATA_PATH) ?: System.getenv(PathConst.ENV_DATA_PATH)
|
System.getProperty(PathConst.PROP_DATA_PATH) ?: System.getenv(PathConst.ENV_DATA_PATH)
|
||||||
?: System.getProperty("user.dir") ?: "."
|
?: System.getProperty("user.dir") ?: "."
|
||||||
@ -125,7 +127,7 @@ internal enum class AppPaths(
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
CONFIG_APPLICATION({ "$DATA_ROOT/config.json" }, {
|
CONFIG_APPLICATION(PathSupplier { "$DATA_ROOT/config.json" }, {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.bufferedWriter(StandardCharsets.UTF_8).use {
|
file.bufferedWriter(StandardCharsets.UTF_8).use {
|
||||||
GsonConst.appConfigGson.toJson(
|
GsonConst.appConfigGson.toJson(
|
||||||
@ -141,7 +143,7 @@ internal enum class AppPaths(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
CONFIG_BOT({ "$DATA_ROOT/bot.json" }, {
|
CONFIG_BOT(PathSupplier { "$DATA_ROOT/bot.json" }, {
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.bufferedWriter(StandardCharsets.UTF_8).use {
|
file.bufferedWriter(StandardCharsets.UTF_8).use {
|
||||||
GsonConst.botConfigGson.toJson(
|
GsonConst.botConfigGson.toJson(
|
||||||
@ -167,10 +169,25 @@ internal enum class AppPaths(
|
|||||||
TEMP({ "$DATA_ROOT/tmp/" })
|
TEMP({ "$DATA_ROOT/tmp/" })
|
||||||
;
|
;
|
||||||
|
|
||||||
val file: File
|
constructor(pathSupplier: PathSupplier, initializer: AppPaths.() -> Unit = AppPaths::defaultInitializer) : this(
|
||||||
get() = fileSupplier.invoke()
|
fileSupplier = FileSupplier { File(pathSupplier.path).canonicalFile },
|
||||||
val path: String
|
pathSupplier = pathSupplier,
|
||||||
get() = pathSupplier.invoke()
|
initializer = initializer
|
||||||
|
)
|
||||||
|
|
||||||
|
constructor(fileSupplier: FileSupplier, initializer: AppPaths.() -> Unit = AppPaths::defaultInitializer) : this(
|
||||||
|
fileSupplier = fileSupplier,
|
||||||
|
pathSupplier = PathSupplier { fileSupplier.file.canonicalPath },
|
||||||
|
initializer = initializer
|
||||||
|
)
|
||||||
|
|
||||||
|
constructor(pathSupplier: () -> String) : this(
|
||||||
|
fileSupplier = FileSupplier { File(pathSupplier.invoke()).canonicalFile },
|
||||||
|
pathSupplier = PathSupplier { pathSupplier.invoke() }
|
||||||
|
)
|
||||||
|
|
||||||
|
val file: File by fileSupplier
|
||||||
|
val path: String by pathSupplier
|
||||||
|
|
||||||
private val initialized = AtomicBoolean(false)
|
private val initialized = AtomicBoolean(false)
|
||||||
|
|
||||||
@ -206,6 +223,20 @@ internal enum class AppPaths(
|
|||||||
const val ENV_DATA_PATH = "BOT_DATA_PATH"
|
const val ENV_DATA_PATH = "BOT_DATA_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class FileSupplier(private val supplier: Supplier<File>) {
|
||||||
|
operator fun getValue(appPaths: AppPaths, property: KProperty<*>): File = supplier.get()
|
||||||
|
|
||||||
|
val file: File
|
||||||
|
get() = supplier.get()
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PathSupplier(private val supplier: Supplier<String>) {
|
||||||
|
operator fun getValue(appPaths: AppPaths, property: KProperty<*>): String = supplier.get()
|
||||||
|
|
||||||
|
val path: String
|
||||||
|
get() = supplier.get()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +182,7 @@ internal class Launcher(private val config: AppConfig = Const.config) : AutoClos
|
|||||||
it.url == MavenRepositoryExtensionFinder.MAVEN_CENTRAL_URL
|
it.url == MavenRepositoryExtensionFinder.MAVEN_CENTRAL_URL
|
||||||
|| it.url == MavenRepositoryExtensionFinder.MAVEN_CENTRAL_URL.trimEnd('/')
|
|| it.url == MavenRepositoryExtensionFinder.MAVEN_CENTRAL_URL.trimEnd('/')
|
||||||
}) {
|
}) {
|
||||||
add(MavenRepositoryExtensionFinder.getMavenCentralRepository(proxy = config.proxy.toAetherProxy()))
|
add(MavenRepositoryExtensionFinder.getMavenCentralRepository(proxy = proxyConfig.toAetherProxy()))
|
||||||
}
|
}
|
||||||
}.toList()
|
}.toList()
|
||||||
val extensionPackageFinders = setOf(
|
val extensionPackageFinders = setOf(
|
||||||
|
@ -413,14 +413,14 @@ internal class ExtensionClassLoader(urls: Array<URL>, dependencyLoader: ClassLoa
|
|||||||
// 以免使用了不来自扩展包的机器人扩展.
|
// 以免使用了不来自扩展包的机器人扩展.
|
||||||
|
|
||||||
override fun getResources(name: String?): Enumeration<URL> {
|
override fun getResources(name: String?): Enumeration<URL> {
|
||||||
if (BotExtensionFactory::class.java.equals(name)) {
|
if ("META-INF/services/${BotExtensionFactory::class.java.name}" == name) {
|
||||||
return findResources(name)
|
return findResources(name)
|
||||||
}
|
}
|
||||||
return super.getResources(name)
|
return super.getResources(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getResource(name: String?): URL? {
|
override fun getResource(name: String?): URL? {
|
||||||
if (BotExtensionFactory::class.java.equals(name)) {
|
if ("META-INF/services/${BotExtensionFactory::class.java}" == name) {
|
||||||
return findResource(name)
|
return findResource(name)
|
||||||
}
|
}
|
||||||
return super.getResource(name)
|
return super.getResource(name)
|
||||||
|
@ -74,7 +74,7 @@ fun <T : AutoCloseable> T.registerShutdownHook(): T {
|
|||||||
private object UtilsInternal {
|
private object UtilsInternal {
|
||||||
|
|
||||||
val autoCloseableSet = mutableSetOf<AutoCloseable>()
|
val autoCloseableSet = mutableSetOf<AutoCloseable>()
|
||||||
private val log = KotlinLogging.logger { }
|
private val log = KotlinLogging.logger(UtilsInternal::class.java.name)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Runtime.getRuntime().addShutdownHook(Thread(this::doCloseResources, "Shutdown-AutoCloseable"))
|
Runtime.getRuntime().addShutdownHook(Thread(this::doCloseResources, "Shutdown-AutoCloseable"))
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<appender name="FILE_OUT" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="FILE_OUT" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${DATA_LOGS}/latest.log</file>
|
<file>${DATA_LOGS}/latest.log</file>
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<fileNamePattern>data/logs/%d{yyyy-MM-dd}.log.gz</fileNamePattern>
|
<fileNamePattern>${DATA_LOGS}/%d{yyyy-MM-dd}.log.gz</fileNamePattern>
|
||||||
<maxHistory>30</maxHistory>
|
<maxHistory>30</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
|
@ -21,6 +21,17 @@ import kotlin.test.*
|
|||||||
|
|
||||||
internal class AppPathsTest {
|
internal class AppPathsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `Consistency check`() {
|
||||||
|
for (path in AppPaths.values()) {
|
||||||
|
assertEquals(
|
||||||
|
File(path.path).canonicalPath,
|
||||||
|
path.file.canonicalPath,
|
||||||
|
"路径 File 与 Path 不一致: ${path.name}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Data root path priority`() {
|
fun `Data root path priority`() {
|
||||||
System.setProperty(AppPaths.PathConst.PROP_DATA_PATH, "fromSystemProperties")
|
System.setProperty(AppPaths.PathConst.PROP_DATA_PATH, "fromSystemProperties")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
java
|
java
|
||||||
|
jacoco
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
signing
|
signing
|
||||||
}
|
}
|
||||||
@ -29,6 +30,16 @@ java {
|
|||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
|
finalizedBy(tasks.jacocoTestReport)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jacocoTestReport {
|
||||||
|
dependsOn(tasks.test)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
@ -36,6 +36,11 @@ java {
|
|||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
isReproducibleFileOrder = true
|
||||||
|
}
|
||||||
|
|
||||||
tasks.getByName<Test>("test") {
|
tasks.getByName<Test>("test") {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,13 @@ data class BotAccount(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 机器人配置.
|
* 机器人配置.
|
||||||
|
*
|
||||||
|
* 使用 Gson 解析时, 请添加以下类型适配器:
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.ProxyTypeSerializer]
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.BotConfigSerializer]
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.BotAccountSerializer]
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.ArtifactSerializer]
|
||||||
|
*
|
||||||
* @property enabled 是否启用机器人.
|
* @property enabled 是否启用机器人.
|
||||||
* @property account 机器人帐号信息, 用于访问 API.
|
* @property account 机器人帐号信息, 用于访问 API.
|
||||||
* @property disableBuiltInAbility 是否禁用 AbilityBot 自带命令.
|
* @property disableBuiltInAbility 是否禁用 AbilityBot 自带命令.
|
||||||
@ -126,6 +133,13 @@ data class MavenRepositoryConfig(
|
|||||||
* ScalaBot App 配置.
|
* ScalaBot App 配置.
|
||||||
*
|
*
|
||||||
* App 配置信息与 BotConfig 分开, 分别存储在各自单独的文件中.
|
* App 配置信息与 BotConfig 分开, 分别存储在各自单独的文件中.
|
||||||
|
*
|
||||||
|
* 使用 Gson 解析时, 请添加以下类型适配器:
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.ProxyTypeSerializer]
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.MavenRepositoryConfigSerializer]
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.AuthenticationSerializer]
|
||||||
|
* - [net.lamgc.scalabot.config.serializer.UsernameAuthenticatorSerializer]
|
||||||
|
*
|
||||||
* @property proxy Telegram API 代理配置.
|
* @property proxy Telegram API 代理配置.
|
||||||
* @property metrics 运行指标数据配置. 可通过时序数据库记录运行数据.
|
* @property metrics 运行指标数据配置. 可通过时序数据库记录运行数据.
|
||||||
* @property mavenRepositories Maven 远端仓库配置.
|
* @property mavenRepositories Maven 远端仓库配置.
|
||||||
|
@ -219,6 +219,12 @@ internal class ProxyConfigTest {
|
|||||||
assertEquals(8080, actualConfig.port)
|
assertEquals(8080, actualConfig.port)
|
||||||
assertEquals(ProxyType.HTTP, actualConfig.type)
|
assertEquals(ProxyType.HTTP, actualConfig.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `toString test`() {
|
||||||
|
assertEquals("NO_PROXY", ProxyConfig(ProxyType.NO_PROXY).toString())
|
||||||
|
assertEquals("HTTP://example.org:1008", ProxyConfig(ProxyType.HTTP, "example.org", 1008).toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class MetricsConfigTest {
|
internal class MetricsConfigTest {
|
||||||
|
Reference in New Issue
Block a user