Skip to content

Commit

Permalink
[6.1.0][dev] 调整 RuntimeEnv 加载逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Bkm016 committed Mar 25, 2024
1 parent 4647b2e commit 9b3f151
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions common-env/src/main/java/taboolib/common/env/RuntimeEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,21 @@ public class RuntimeEnv {

static void init() throws Throwable {
List<JarRelocation> rel = new ArrayList<>();
// 启用 Kotlin 重定向
if (!PrimitiveSettings.SKIP_KOTLIN_RELOCATE) {
rel.add(new JarRelocation(KOTLIN_ID + ".", PrimitiveSettings.getRelocatedKotlinVersion() + "."));
rel.add(new JarRelocation(KOTLIN_COROUTINES_ID + ".", PrimitiveSettings.getRelocatedKotlinCoroutinesVersion() + "."));
}
boolean loadKotlin = !KOTLIN_VERSION.equals("null");
boolean loadKotlinCoroutines = !KOTLIN_COROUTINES_VERSION.equals("null");
// 在非隔离模式下检查 Kotlin 环境
if (!PrimitiveSettings.IS_ISOLATED_MODE) {
// 加载 Kotlin 环境
if (!KOTLIN_VERSION.equals("null") && !TabooLib.isKotlinEnvironment()) {
ENV.loadDependency("org.jetbrains.kotlin:kotlin-stdlib:" + KOTLIN_VERSION, rel);
}
// 加载 Kotlin Coroutines 环境
if (!KOTLIN_COROUTINES_VERSION.equals("null") && !TabooLib.isKotlinCoroutinesEnvironment()) {
ENV.loadDependency("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + KOTLIN_COROUTINES_VERSION, false, rel);
}
// 非隔离模式下的重定向规则
rel.add(new JarRelocation(KOTLIN_ID + ".", PrimitiveSettings.getRelocatedKotlinVersion() + "."));
rel.add(new JarRelocation(KOTLIN_COROUTINES_ID + ".", PrimitiveSettings.getRelocatedKotlinCoroutinesVersion() + "."));
// 环境检查
if (TabooLib.isKotlinEnvironment()) loadKotlin = false;
if (TabooLib.isKotlinCoroutinesEnvironment()) loadKotlinCoroutines = false;
}
// 加载 Kotlin 环境
if (loadKotlin) ENV.loadDependency("org.jetbrains.kotlin:kotlin-stdlib:" + KOTLIN_VERSION, rel);
// 加载 Kotlin Coroutines 环境
if (loadKotlinCoroutines) ENV.loadDependency("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:" + KOTLIN_COROUTINES_VERSION, false, rel);
}

public void inject(@NotNull Class<?> clazz) throws Throwable {
Expand Down

0 comments on commit 9b3f151

Please sign in to comment.