From 35fbcbda42c907009f911a45c1f7c2da9b5aaeeb Mon Sep 17 00:00:00 2001 From: SuperMonster003 Date: Thu, 9 Oct 2025 17:51:09 +0800 Subject: [PATCH] =?UTF-8?q?6.7.0=20-=20Alpha6=20-=20=E4=BD=BF=E7=94=A8=20G?= =?UTF-8?q?radle=20=E7=BA=A6=E5=AE=9A=E6=8F=92=E4=BB=B6=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=20AAR=20=E5=BA=93=E5=8A=A0=E8=BD=BD=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changelog/lang_zh-Hans.json | 1 + build-logic/convention/build.gradle.kts | 6 +++++ .../build/LocalAarRegisterConventionPlugin.kt | 26 +++++++++++++++++++ build.gradle.kts | 2 -- libs/android-assertion-9_0_0/build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- libs/android-spackle-9_0_0/build.gradle.kts | 16 +++++------- .../androidx-appcompat-1_0_2/build.gradle.kts | 16 +++++------- libs/apk-parser-1_0_2/build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- libs/expandable-layout-1_6_0/build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- libs/markwon-core-4_6_2/build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- libs/org-opencv-4_8_0/build.gradle.kts | 16 +++++------- .../build.gradle.kts | 16 +++++------- libs/root-shell-1_6/build.gradle.kts | 16 +++++------- settings.gradle.kts | 1 - version.properties | 4 +-- 22 files changed, 147 insertions(+), 149 deletions(-) create mode 100644 build-logic/convention/src/main/kotlin/org/autojs/build/LocalAarRegisterConventionPlugin.kt diff --git a/.changelog/lang_zh-Hans.json b/.changelog/lang_zh-Hans.json index 3883c4a1..a912aaa6 100644 --- a/.changelog/lang_zh-Hans.json +++ b/.changelog/lang_zh-Hans.json @@ -46,6 +46,7 @@ "Gradle 构建脚本支持自动生成 VersionCodesList 类所需数据以降低脚本启动延迟", "使用版本目录 (Version Catalogs) 集中管理 Gradle 依赖和插件版本", "模块化 Gradle 构建脚本, 将共享构建逻辑迁移至 buildSrc 并抽象为约定插件", + "使用 Gradle 约定插件简化本地 AAR 库加载逻辑", "使用 Toolchain 替代 sourceCompatibility/targetCompatibility 以降低构建环境差异" ], "dependency": [ diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index ce98afa2..88fb7bbe 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -47,6 +47,12 @@ gradlePlugin { displayName = "AutoJs6 JVM Convention Plugin" description = "Configures Java/Kotlin targets for Android modules using central Versions." } + register("localAarRegisterConvention") { + id = "org.autojs.build.local-arr-register-convention" + implementationClass = "org.autojs.build.LocalAarRegisterConventionPlugin" + displayName = "AutoJs6 Local AAR Register Convention Plugin" + description = "Provides local AAR register helpers." + } } } diff --git a/build-logic/convention/src/main/kotlin/org/autojs/build/LocalAarRegisterConventionPlugin.kt b/build-logic/convention/src/main/kotlin/org/autojs/build/LocalAarRegisterConventionPlugin.kt new file mode 100644 index 00000000..ac15a588 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/org/autojs/build/LocalAarRegisterConventionPlugin.kt @@ -0,0 +1,26 @@ +@file:Suppress("unused") + +package org.autojs.build + +import org.gradle.api.Plugin +import org.gradle.api.Project + +open class LocalAarExtension { + val files = mutableListOf() + var configurationName: String? = null +} + +class LocalAarRegisterConventionPlugin : Plugin { + override fun apply(project: Project) { + val ext = project.extensions.create("localAars", LocalAarExtension::class.java) + project.afterEvaluate { + val configName = ext.configurationName ?: "default" + configurations.maybeCreate(configName) + ext.files.forEach { path -> + val aar = file(path) + require(aar.exists()) { "File not found: \"$path\"" } + artifacts.add(configName, aar) + } + } + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 15b2f77b..0441f4bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,8 +4,6 @@ // ! Blocks "buildscript" and "plugins" have been moved to "settings.gradle.kts". // ! zh-CN: 代码块 "buildscript" 以及 "plugins" 已迁移至 "settings.gradle.kts". -extra["configurationName"] = "default" - allprojects { repositories { mavenCentral() diff --git a/libs/android-assertion-9_0_0/build.gradle.kts b/libs/android-assertion-9_0_0/build.gradle.kts index fe826f59..c3cd9923 100644 --- a/libs/android-assertion-9_0_0/build.gradle.kts +++ b/libs/android-assertion-9_0_0/build.gradle.kts @@ -1,9 +1,7 @@ -"android-assertion-9.0.0.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "android-assertion-9.0.0.aar" +} diff --git a/libs/android-job-simplified-1_4_3/build.gradle.kts b/libs/android-job-simplified-1_4_3/build.gradle.kts index 01f7d883..c9e985f8 100644 --- a/libs/android-job-simplified-1_4_3/build.gradle.kts +++ b/libs/android-job-simplified-1_4_3/build.gradle.kts @@ -1,12 +1,10 @@ // @Modified // ! Current library (Android Job) was simplified by SuperMonster003 on Jun 30, 2022. -"android-job-simplified.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "android-job-simplified.aar" +} diff --git a/libs/android-plugin-client-sdk-for-locale-9_0_0/build.gradle.kts b/libs/android-plugin-client-sdk-for-locale-9_0_0/build.gradle.kts index 970515a7..b8b89c05 100644 --- a/libs/android-plugin-client-sdk-for-locale-9_0_0/build.gradle.kts +++ b/libs/android-plugin-client-sdk-for-locale-9_0_0/build.gradle.kts @@ -1,9 +1,7 @@ -"android-plugin-client-sdk-for-locale-9.0.0.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "android-plugin-client-sdk-for-locale-9.0.0.aar" +} diff --git a/libs/android-spackle-9_0_0/build.gradle.kts b/libs/android-spackle-9_0_0/build.gradle.kts index 84e528d7..8996190f 100644 --- a/libs/android-spackle-9_0_0/build.gradle.kts +++ b/libs/android-spackle-9_0_0/build.gradle.kts @@ -1,9 +1,7 @@ -"android-spackle-9.0.0.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "android-spackle-9.0.0.aar" +} diff --git a/libs/androidx-appcompat-1_0_2/build.gradle.kts b/libs/androidx-appcompat-1_0_2/build.gradle.kts index dff1bbd5..085a2cd0 100644 --- a/libs/androidx-appcompat-1_0_2/build.gradle.kts +++ b/libs/androidx-appcompat-1_0_2/build.gradle.kts @@ -1,9 +1,7 @@ -"appcompat-legacy.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "appcompat-legacy.aar" +} diff --git a/libs/apk-parser-1_0_2/build.gradle.kts b/libs/apk-parser-1_0_2/build.gradle.kts index e53f55f0..00b4c5bb 100644 --- a/libs/apk-parser-1_0_2/build.gradle.kts +++ b/libs/apk-parser-1_0_2/build.gradle.kts @@ -1,9 +1,7 @@ -"apk-parser-1.0.2.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "apk-parser-1.0.2.aar" +} diff --git a/libs/com-tencent-bugly-crashreport-4_0_4/build.gradle.kts b/libs/com-tencent-bugly-crashreport-4_0_4/build.gradle.kts index a18b9ef3..45d83723 100644 --- a/libs/com-tencent-bugly-crashreport-4_0_4/build.gradle.kts +++ b/libs/com-tencent-bugly-crashreport-4_0_4/build.gradle.kts @@ -1,9 +1,7 @@ -"crashreport-4.0.4.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "crashreport-4.0.4.aar" +} diff --git a/libs/expandable-layout-1_6_0/build.gradle.kts b/libs/expandable-layout-1_6_0/build.gradle.kts index 5a2467b1..42049c16 100644 --- a/libs/expandable-layout-1_6_0/build.gradle.kts +++ b/libs/expandable-layout-1_6_0/build.gradle.kts @@ -1,9 +1,7 @@ -"expandable-layout-1.6.0.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "expandable-layout-1.6.0.aar" +} diff --git a/libs/jackpal-androidterm-1_0_70/build.gradle.kts b/libs/jackpal-androidterm-1_0_70/build.gradle.kts index bdf120de..bba54b04 100644 --- a/libs/jackpal-androidterm-1_0_70/build.gradle.kts +++ b/libs/jackpal-androidterm-1_0_70/build.gradle.kts @@ -1,9 +1,7 @@ -"term-debug.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "term-debug.aar" +} diff --git a/libs/jackpal-androidterm-emulatorview-1_0_42/build.gradle.kts b/libs/jackpal-androidterm-emulatorview-1_0_42/build.gradle.kts index 0ccc4ffc..8bae9119 100644 --- a/libs/jackpal-androidterm-emulatorview-1_0_42/build.gradle.kts +++ b/libs/jackpal-androidterm-emulatorview-1_0_42/build.gradle.kts @@ -1,9 +1,7 @@ -"emulatorview-release.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "emulatorview-release.aar" +} diff --git a/libs/jackpal-androidterm-libtermexec-1_0/build.gradle.kts b/libs/jackpal-androidterm-libtermexec-1_0/build.gradle.kts index 1f6d2685..3af011d0 100644 --- a/libs/jackpal-androidterm-libtermexec-1_0/build.gradle.kts +++ b/libs/jackpal-androidterm-libtermexec-1_0/build.gradle.kts @@ -1,9 +1,7 @@ -"libtermexec-release.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "libtermexec-release.aar" +} diff --git a/libs/markwon-core-4_6_2/build.gradle.kts b/libs/markwon-core-4_6_2/build.gradle.kts index 8542ac4f..b2005973 100644 --- a/libs/markwon-core-4_6_2/build.gradle.kts +++ b/libs/markwon-core-4_6_2/build.gradle.kts @@ -1,9 +1,7 @@ -"markwon-core-4.6.2.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "markwon-core-4.6.2.aar" +} diff --git a/libs/markwon-syntax-highlight-4_6_2/build.gradle.kts b/libs/markwon-syntax-highlight-4_6_2/build.gradle.kts index cfd2c705..861bbfcd 100644 --- a/libs/markwon-syntax-highlight-4_6_2/build.gradle.kts +++ b/libs/markwon-syntax-highlight-4_6_2/build.gradle.kts @@ -1,9 +1,7 @@ -"markwon-syntax-highlight-4.6.2.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "markwon-syntax-highlight-4.6.2.aar" +} diff --git a/libs/org-opencv-4_8_0/build.gradle.kts b/libs/org-opencv-4_8_0/build.gradle.kts index 066eeadc..0451d5e2 100644 --- a/libs/org-opencv-4_8_0/build.gradle.kts +++ b/libs/org-opencv-4_8_0/build.gradle.kts @@ -1,12 +1,10 @@ // @Reference // ! Current library (OpenCV) was referred to TonyJiangWJ/Auto.js (https://github.com/TonyJiangWJ/Auto.js) on Oct 18, 2022. -"opencv-4.8.0.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "opencv-4.8.0.aar" +} diff --git a/libs/recyclerview-flexibledivider-1_4_0/build.gradle.kts b/libs/recyclerview-flexibledivider-1_4_0/build.gradle.kts index 518d09fa..23d4676e 100644 --- a/libs/recyclerview-flexibledivider-1_4_0/build.gradle.kts +++ b/libs/recyclerview-flexibledivider-1_4_0/build.gradle.kts @@ -1,9 +1,7 @@ -"recyclerview-flexibledivider-1.4.0.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "recyclerview-flexibledivider-1.4.0.aar" +} diff --git a/libs/root-shell-1_6/build.gradle.kts b/libs/root-shell-1_6/build.gradle.kts index 80681135..140c840c 100644 --- a/libs/root-shell-1_6/build.gradle.kts +++ b/libs/root-shell-1_6/build.gradle.kts @@ -1,9 +1,7 @@ -"root-shell-1.6.aar" - .let { path -> - rootProject.extra["configurationName"].toString().let { name -> - configurations.maybeCreate(name) - file(path).takeIf { it.exists() }?.also { - artifacts.add(name, it) - } ?: throw Exception("File not found: \"$path\"") - } - } \ No newline at end of file +plugins { + id("org.autojs.build.local-arr-register-convention") +} + +localAars { + files += "root-shell-1.6.aar" +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 8d6afff9..ac47ad50 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,5 @@ @file:Suppress("SpellCheckingInspection") - enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") rootProject.name = "root" diff --git a/version.properties b/version.properties index 54fffc45..52b0fbe5 100644 --- a/version.properties +++ b/version.properties @@ -1,5 +1,5 @@ -#Thu Oct 09 17:07:45 CST 2025 -BUILD_TIME=1760000865200 +#Thu Oct 09 17:46:30 CST 2025 +BUILD_TIME=1760003190056 COMPILE_SDK_VERSION=36 IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_NDK_VERSION=26.1.10909125