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

@@ -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."
}
}
}

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)
}
}
}
}