feat:plugin编译为aar包引用

This commit is contained in:
2025-09-22 11:12:45 +08:00
parent 0509096925
commit e04110c6d5
8 changed files with 36 additions and 4 deletions

View File

@@ -7,6 +7,9 @@ buildscript {
maven { url file("mavenLocal") }
google()
mavenCentral()
maven {
url "https://storage.googleapis.com/download.flutter.io"
}
}
dependencies {
@@ -20,6 +23,9 @@ allprojects {
maven { url file("mavenLocal") }
google()
mavenCentral()
maven {
url "https://storage.googleapis.com/download.flutter.io"
}
}
}
@@ -74,6 +80,17 @@ android {
throw new GradleException("Flutter SDK not found. Define location with flutter.")
}
// 找到 flutter.jar 文件
def flutterJar = new File(flutterRoot, "bin/cache/artifacts/engine/android-arm/flutter.jar")
if (!flutterJar.exists()) {
// 尝试其他路径
flutterJar = new File(flutterRoot, "bin/cache/artifacts/engine/android-arm-release/flutter.jar")
}
if (!flutterJar.exists()) {
// Windows 上可能在这个位置
flutterJar = new File(flutterRoot, "bin/cache/artifacts/engine/android-x64/flutter.jar")
}
repositories {
flatDir {
dirs("libs")
@@ -83,7 +100,12 @@ android {
dependencies {
implementation 'com.alibaba.idst:nui-release:1.0.0'
implementation 'com.alibaba:fastjson:1.2.83'
// 使用Flutter的官方Maven依赖
// compileOnly 'io.flutter:flutter_embedding_debug:1.0.0-3.27.4'
// 或者使用release版本
// compileOnly '"io.flutter:flutter_embedding_release:1.0.0-de555ebd6cfe3e606a101b9ae45bbf5e62d4e4e1"'
// compileOnly files("$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar")
compileOnly files(files("libs/flutter.jar"))
// implementation(files("libs/fastjson-1.1.46.android.jar"))
// implementation(files("libs/nui-release-1.0.0.aar"))
}

File diff suppressed because one or more lines are too long

BIN
android/libs/flutter.jar Normal file

Binary file not shown.

View File

@@ -50,3 +50,11 @@ android {
flutter {
source = "../.."
}
dependencies {
// Process .aar files in the libs folder.
val aarFiles = fileTree(mapOf("dir" to "$rootDir/libs", "include" to listOf("*.aar")))
aarFiles.forEach { aar ->
implementation(files(aar))
}
}

View File

@@ -1,8 +1,8 @@
allprojects {
repositories {
val mavenLocalPath = rootProject.file("../../android/mavenLocal")
println("Maven local path: ${mavenLocalPath.absolutePath}")
println("Maven local exists: ${mavenLocalPath.exists()}")
// println("Maven local path: ${mavenLocalPath.absolutePath}")
// println("Maven local exists: ${mavenLocalPath.exists()}")
maven { url = uri(mavenLocalPath) }

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -19,6 +19,8 @@ pluginManagement {
google()
mavenCentral()
gradlePluginPortal()
flatDir { dirs(file("libs")) }
}
}