6.7.0 - Alpha6 - 使用 Gradle 约定插件简化本地 AAR 库加载逻辑
This commit is contained in:
@@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user