Skip to content

Commit

Permalink
Experimental | Support Kotlin Script(.kts)
Browse files Browse the repository at this point in the history
我猜它肯定报错
脚本模块需要重构
  • Loading branch information
TheFloodDragon committed Jul 14, 2024
1 parent e7e28dc commit bc542e8
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 5 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const val rootGroup = "cn.fd.ratziel"
const val rootVersion = "A.0.3.0.8"

const val kotlinVersion = "2.0.0"
const val serializationVersion = "1.7.0"
const val serializationVersion = "1.7.1"
const val coroutineVersion = "1.8.1"
const val shadowJarVersion = "8.1.1"
const val taboolibPluginVersion = "2.0.11"

const val taboolibVersion = "6.1.2-test1"
const val taboolibVersion = "6.1.2-beta10"

val adventureModules = setOf(
"net.kyori:adventure-api:4.17.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
* @since 2023/8/23 16:20
*/
@RuntimeDependencies({
@RuntimeDependency(value = "org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.6.3", test = "!kotlinx.serialization.KSerializer", transitive = false),
@RuntimeDependency(value = "org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.6.3", test = "!kotlinx.serialization.json.JsonElement", transitive = false)
@RuntimeDependency(value = "!org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.7.1", test = "!kotlinx.serialization.KSerializer", transitive = false),
@RuntimeDependency(value = "!org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.1", test = "!kotlinx.serialization.json.JsonElement", transitive = false)
})
public class CoreEnv {
public static final String KOTLIN_VERSION = "2.0.0";
}
12 changes: 12 additions & 0 deletions project/module-script/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
dependencies {
// Kotlin Script
compileOnly(kotlin("scripting-common"))
compileOnly(kotlin("scripting-jvm"))
compileOnly(kotlin("scripting-jvm-host"))
compileOnly(kotlin("scripting-compiler"))
compileOnly(kotlin("scripting-jsr223"))
compileOnly("org.jetbrains.kotlin:kotlin-main-kts:$kotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion")
compileOnly("org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:$kotlinVersion")
// Kether: Taboolib
compileTaboo("module-kether")
// JavaScript: Nashorn Engine
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cn.fd.ratziel.core.env;

import taboolib.common.env.RuntimeDependencies;
import taboolib.common.env.RuntimeDependency;

/**
* ScriptEnv
*
* @author TheFloodDragon
* @since 2024/7/14 14:54
*/
@RuntimeDependencies({
// Kotlin Script
@RuntimeDependency(
value = "!org.jetbrains.kotlin:kotlin-script-runtime:" + CoreEnv.KOTLIN_VERSION,
transitive = false
),
@RuntimeDependency(
value = "!org.jetbrains.kotlin:kotlin-script-common:" + CoreEnv.KOTLIN_VERSION,
transitive = false
),
@RuntimeDependency(
value = "!org.jetbrains.kotlin:kotlin-script-jvm:" + CoreEnv.KOTLIN_VERSION,
transitive = false
),
@RuntimeDependency(
value = "!org.jetbrains.kotlin:kotlin-script-jvm-host:" + CoreEnv.KOTLIN_VERSION,
transitive = false
),
@RuntimeDependency(
value = "!org.jetbrains.kotlin:kotlin-script-compiler:" + CoreEnv.KOTLIN_VERSION,
transitive = false
),
@RuntimeDependency(
value = "!org.jetbrains.kotlin:kotlin-script-jsr233:" + CoreEnv.KOTLIN_VERSION,
transitive = false
),
// JavaScript
@RuntimeDependency(
value = "!org.openjdk.nashorn:nashorn-core:15.4",
test = "!org.openjdk.nashorn.api.scripting.NashornScriptEngine"
),
// Jexl
@RuntimeDependency(
value = "!org.apache.commons:commons-jexl3:3.4.0",
test = "!org.apache.commons.jexl3.JexlEngine"
)}
)
public class ScriptEnv {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cn.fd.ratziel.script

/**
* KotlinScriptLang
*
* @author TheFloodDragon
* @since 2024/7/14 15:40
*/
object KotlinScriptLang : EnginedScriptLanguage(
"kts", // 引擎名称
"kts", "KTS", "KotlinScript", "kotlin-script", "KotlinScripting", "kotlin-scripting" // 语言名称
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object ScriptManager {
* |- Kether, JavaScript, Jexl3
*/
@JvmStatic
var scriptLanguages: Array<ScriptLanguage> = arrayOf(KetherLang, JavaScriptLang, JexlLang)
var scriptLanguages: Array<ScriptLanguage> = arrayOf(KetherLang, JavaScriptLang, JexlLang, KotlinScriptLang)
private set

/**
Expand Down

0 comments on commit bc542e8

Please sign in to comment.