Skip to content

Commit

Permalink
Merge pull request #914 from simple-robot/apply-buildConfig-for-lib-v…
Browse files Browse the repository at this point in the history
…ersion

在 simbot-api 中生成携带部分常量信息的 builtin
  • Loading branch information
ForteScarlet authored Aug 9, 2024
2 parents d57f4c6 + f58c080 commit 18611d8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
9 changes: 6 additions & 3 deletions buildSrc/src/main/kotlin/JsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ inline fun KotlinJsTargetDsl.configJs(
nodejs {
testTask {
useMocha {
timeout = "10000"
timeout = "50000"
}
}
}
Expand All @@ -46,7 +46,6 @@ inline fun KotlinJsTargetDsl.configJs(
testTask {
useKarma {
useChromeHeadless()
// useConfigDirectory(File(project.rootProject.projectDir, "karma"))
}
}
}
Expand Down Expand Up @@ -75,6 +74,11 @@ inline fun KotlinWasmJsTargetDsl.configWasmJs(
) {
if (nodeJs) {
nodejs {
testTask {
useMocha {
timeout = "50000"
}
}
}
}
// if (nodeJs && isLinux) {
Expand All @@ -87,7 +91,6 @@ inline fun KotlinWasmJsTargetDsl.configWasmJs(
testTask {
useKarma {
useChromeHeadless()
// useConfigDirectory(File(project.rootProject.projectDir, "karma"))
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions simbot-api/api/simbot-api.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
public final class love/forte/simbot/SimbotBuiltin {
public static final field BUILD_AT Ljava/lang/String;
public static final field BUILD_KOTLIN_VERSION Ljava/lang/String;
public static final field INSTANCE Llove/forte/simbot/SimbotBuiltin;
public static final field IS_SNAPSHOT Z
public static final field VERSION Ljava/lang/String;
}

public abstract interface class love/forte/simbot/ability/AcceptOption {
}

Expand Down
20 changes: 19 additions & 1 deletion simbot-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import love.forte.gradle.common.kotlin.multiplatform.applyTier2
import love.forte.gradle.common.kotlin.multiplatform.applyTier3
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import java.time.Instant

plugins {
kotlin("multiplatform")
Expand All @@ -34,8 +35,8 @@ plugins {
id("simbot.suspend-transform-configure")
alias(libs.plugins.ksp)
id("simbot.dokka-module-configuration")
id("com.github.gmazzo.buildconfig")
}
// apply(plugin = "simbot.dokka-module-configuration")

configJavaCompileWithModule("simbot.api")
apply(plugin = "simbot-multiplatform-maven-publish")
Expand Down Expand Up @@ -145,3 +146,20 @@ ksp {
arg("simbot.internal.processor.uml.output", rootDir.resolve("generated-docs/event-uml.md").absolutePath)
// arg("simbot.internal.processor.uml.output", rootDir.resolve("generated-docs/actor-uml.md").absolutePath)
}

// BuildConfig for the current version
// love.forte.simbot.annotations.InternalSimbotAPI
buildConfig {
useKotlinOutput {
topLevelConstants = false
internalVisibility = false
}

className.set("SimbotBuiltin")
packageName.set("love.forte.simbot")
buildConfigField<String>("VERSION", P.Simbot.version)
buildConfigField<String>("BUILD_KOTLIN_VERSION", libs.versions.kotlin)
buildConfigField<Boolean>("IS_SNAPSHOT", isSnapshot())
buildConfigField<String>("BUILD_AT", Instant.now().toString())
documentation.set("Auto-generated simbot built-in constants.")
}
1 change: 1 addition & 0 deletions simbot-api/src/jvmMain/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
requires static org.reactivestreams;

// libs.suspend.reversal.annotations?
exports love.forte.simbot;
exports love.forte.simbot.ability;
exports love.forte.simbot.application;
exports love.forte.simbot.bot;
Expand Down

0 comments on commit 18611d8

Please sign in to comment.