6.7.0 - Alpha6 - 使用 Toolchain 替代 sourceCompatibility/targetCompatibility 以降低构建环境差异

This commit is contained in:
SuperMonster003
2025-09-24 16:47:39 +08:00
parent 4778794e0e
commit 2309377f97
18 changed files with 361 additions and 228 deletions

View File

@@ -52,6 +52,14 @@ gradlePlugin {
t.description = "Provides properties helpers."
}
})
create("jvmConvention", object : Action<PluginDeclaration> {
override fun execute(t: PluginDeclaration) {
t.id = "org.autojs.build.jvm-convention"
t.implementationClass = "org.autojs.build.JvmConventionPlugin"
t.displayName = "AutoJs6 JVM Convention Plugin"
t.description = "Configures Java/Kotlin targets for Android modules using central Versions."
}
})
}
}

View File

@@ -17,3 +17,10 @@ dependencyResolutionManagement {
}
}
}
plugins {
// @Hint by SuperMonster003 on Sep 14, 2025.
// ! Enable JDK auto-resolution/download capability for build modules.
// ! zh-CN: 让构建模块具备 JDK 自动解析/下载能力.
id("org.gradle.toolchains.foojay-resolver-convention")
}

View File

@@ -0,0 +1,32 @@
@file:Suppress("unused")
package org.autojs.build
import org.gradle.api.Plugin
import org.gradle.api.Project
/**
* Convention plugin: Unified Java/Kotlin target version configuration for Android modules.
*
* zh-CN: 约定插件: 为 Android 模块统一配置 Java/Kotlin 目标版本.
*
* - `id`: "org.autojs.build.jvm-convention"
* - `implementationClass`: "org.autojs.build.JvmConventionPlugin"
* - `displayName`: "AutoJs6 JVM Convention Plugin"
* - `description`: "Configures Java/Kotlin targets for Android modules using central Versions."
*
* Apply this plugin to your Android module's `build.gradle.kts`:
*
* zh-CN: 在 Android 模块的 `build.gradle.kts` 中应用此插件:<br>
*
* ```kts
* plugins {
* id("org.autojs.build.jvm-convention")
* }
* ```
*/
class JvmConventionPlugin : Plugin<Project> {
override fun apply(project: Project) {
Utils.configureJvmForAndroidModule(project)
}
}