6.7.0 - Alpha6 - 使用 Gradle 约定插件简化本地 AAR 库加载逻辑

This commit is contained in:
SuperMonster003
2025-10-09 17:51:09 +08:00
parent b83ce13d0e
commit 35fbcbda42
22 changed files with 147 additions and 149 deletions

View File

@@ -46,6 +46,7 @@
"Gradle 构建脚本支持自动生成 VersionCodesList 类所需数据以降低脚本启动延迟", "Gradle 构建脚本支持自动生成 VersionCodesList 类所需数据以降低脚本启动延迟",
"使用版本目录 (Version Catalogs) 集中管理 Gradle 依赖和插件版本", "使用版本目录 (Version Catalogs) 集中管理 Gradle 依赖和插件版本",
"模块化 Gradle 构建脚本, 将共享构建逻辑迁移至 buildSrc 并抽象为约定插件", "模块化 Gradle 构建脚本, 将共享构建逻辑迁移至 buildSrc 并抽象为约定插件",
"使用 Gradle 约定插件简化本地 AAR 库加载逻辑",
"使用 Toolchain 替代 sourceCompatibility/targetCompatibility 以降低构建环境差异" "使用 Toolchain 替代 sourceCompatibility/targetCompatibility 以降低构建环境差异"
], ],
"dependency": [ "dependency": [

View File

@@ -47,6 +47,12 @@ gradlePlugin {
displayName = "AutoJs6 JVM Convention Plugin" displayName = "AutoJs6 JVM Convention Plugin"
description = "Configures Java/Kotlin targets for Android modules using central Versions." 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."
}
} }
} }

View File

@@ -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<String>()
var configurationName: String? = null
}
class LocalAarRegisterConventionPlugin : Plugin<Project> {
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)
}
}
}
}

View File

@@ -4,8 +4,6 @@
// ! Blocks "buildscript" and "plugins" have been moved to "settings.gradle.kts". // ! Blocks "buildscript" and "plugins" have been moved to "settings.gradle.kts".
// ! zh-CN: 代码块 "buildscript" 以及 "plugins" 已迁移至 "settings.gradle.kts". // ! zh-CN: 代码块 "buildscript" 以及 "plugins" 已迁移至 "settings.gradle.kts".
extra["configurationName"] = "default"
allprojects { allprojects {
repositories { repositories {
mavenCentral() mavenCentral()

View File

@@ -1,9 +1,7 @@
"android-assertion-9.0.0.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "android-assertion-9.0.0.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,12 +1,10 @@
// @Modified // @Modified
// ! Current library (Android Job) was simplified by SuperMonster003 on Jun 30, 2022. // ! Current library (Android Job) was simplified by SuperMonster003 on Jun 30, 2022.
"android-job-simplified.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "android-job-simplified.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"android-plugin-client-sdk-for-locale-9.0.0.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "android-plugin-client-sdk-for-locale-9.0.0.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"android-spackle-9.0.0.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "android-spackle-9.0.0.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"appcompat-legacy.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "appcompat-legacy.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"apk-parser-1.0.2.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "apk-parser-1.0.2.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"crashreport-4.0.4.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "crashreport-4.0.4.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"expandable-layout-1.6.0.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "expandable-layout-1.6.0.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"term-debug.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "term-debug.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"emulatorview-release.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "emulatorview-release.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"libtermexec-release.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "libtermexec-release.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"markwon-core-4.6.2.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "markwon-core-4.6.2.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"markwon-syntax-highlight-4.6.2.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "markwon-syntax-highlight-4.6.2.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,12 +1,10 @@
// @Reference // @Reference
// ! Current library (OpenCV) was referred to TonyJiangWJ/Auto.js (https://github.com/TonyJiangWJ/Auto.js) on Oct 18, 2022. // ! Current library (OpenCV) was referred to TonyJiangWJ/Auto.js (https://github.com/TonyJiangWJ/Auto.js) on Oct 18, 2022.
"opencv-4.8.0.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "opencv-4.8.0.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"recyclerview-flexibledivider-1.4.0.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "recyclerview-flexibledivider-1.4.0.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,9 +1,7 @@
"root-shell-1.6.aar" plugins {
.let { path -> id("org.autojs.build.local-arr-register-convention")
rootProject.extra["configurationName"].toString().let { name -> }
configurations.maybeCreate(name)
file(path).takeIf { it.exists() }?.also { localAars {
artifacts.add(name, it) files += "root-shell-1.6.aar"
} ?: throw Exception("File not found: \"$path\"") }
}
}

View File

@@ -1,6 +1,5 @@
@file:Suppress("SpellCheckingInspection") @file:Suppress("SpellCheckingInspection")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
rootProject.name = "root" rootProject.name = "root"

View File

@@ -1,5 +1,5 @@
#Thu Oct 09 17:07:45 CST 2025 #Thu Oct 09 17:46:30 CST 2025
BUILD_TIME=1760000865200 BUILD_TIME=1760003190056
COMPILE_SDK_VERSION=36 COMPILE_SDK_VERSION=36
IMAGE_QUANT_CMAKE_VERSION=3.22.1 IMAGE_QUANT_CMAKE_VERSION=3.22.1
IMAGE_QUANT_NDK_VERSION=26.1.10909125 IMAGE_QUANT_NDK_VERSION=26.1.10909125