From 3a6dca1429c72a5f7a2e227b30b9680e79f63690 Mon Sep 17 00:00:00 2001 From: johnsonlee Date: Wed, 17 Jul 2024 04:27:31 +0900 Subject: [PATCH] Fix `Variant.localAndroidResources` --- .../kotlin/com/didiglobal/booster/gradle/Project.kt | 1 - .../didiglobal/booster/android/gradle/v8_0/V80.kt | 12 ++++++++---- .../didiglobal/booster/android/gradle/v8_1/V81.kt | 12 ++++++++---- .../didiglobal/booster/android/gradle/v8_2/V82.kt | 12 ++++++++---- .../booster/task/graph/GraphVariantProcessor.kt | 1 - 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/Project.kt b/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/Project.kt index 55f7868b..eecaa779 100644 --- a/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/Project.kt +++ b/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/Project.kt @@ -181,7 +181,6 @@ fun Project.getJarTaskProviders( is ApplicationAndroidComponentsExtension -> variants.filter().mapNotNull(Variant::bundleClassesTaskProvider) else -> emptyList() } - isJavaLibrary -> listOf(tasks.named(JavaPlugin.JAR_TASK_NAME)) else -> emptyList() } diff --git a/booster-android-gradle-v8_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_0/V80.kt b/booster-android-gradle-v8_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_0/V80.kt index 95e15540..9addc845 100644 --- a/booster-android-gradle-v8_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_0/V80.kt +++ b/booster-android-gradle-v8_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_0/V80.kt @@ -197,10 +197,14 @@ internal object V80 : AGPInterface { override val Variant.localAndroidResources: FileCollection get() = component.services.fileCollection().from(component.sources.res?.getLocalSources()?.values?.map { it.map { dirs -> - dirs.map { dir -> - dir.asFileTree - }.reduce { acc, dir -> - acc.plus(dir) + if (dirs.isEmpty()) { + project.files() + } else { + dirs.map { dir -> + dir.asFileTree + }.reduce { acc, dir -> + acc.plus(dir) + } } } }) diff --git a/booster-android-gradle-v8_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_1/V81.kt b/booster-android-gradle-v8_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_1/V81.kt index 44274692..a61bba71 100644 --- a/booster-android-gradle-v8_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_1/V81.kt +++ b/booster-android-gradle-v8_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_1/V81.kt @@ -200,10 +200,14 @@ internal object V81 : AGPInterface { !it.isUserAdded && !it.isGenerated }?.values?.map { it.map { dirs -> - dirs.map { dir -> - dir.asFileTree - }.reduce { acc, dir -> - acc.plus(dir) + if (dirs.isEmpty()) { + project.files() + } else { + dirs.map { dir -> + dir.asFileTree + }.reduce { acc, dir -> + acc.plus(dir) + } } } }) diff --git a/booster-android-gradle-v8_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_2/V82.kt b/booster-android-gradle-v8_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_2/V82.kt index ff42131d..54058f94 100644 --- a/booster-android-gradle-v8_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_2/V82.kt +++ b/booster-android-gradle-v8_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v8_2/V82.kt @@ -200,10 +200,14 @@ internal object V82 : AGPInterface { !it.isUserAdded && !it.isGenerated }?.values?.map { it.map { dirs -> - dirs.map { dir -> - dir.asFileTree - }.reduce { acc, dir -> - acc.plus(dir) + if (dirs.isEmpty()) { + project.files() + } else { + dirs.map { dir -> + dir.asFileTree + }.reduce { acc, dir -> + acc.plus(dir) + } } } }) diff --git a/booster-task-graph/src/main/kotlin/com/didiglobal/booster/task/graph/GraphVariantProcessor.kt b/booster-task-graph/src/main/kotlin/com/didiglobal/booster/task/graph/GraphVariantProcessor.kt index 2e36efe2..b33c9781 100644 --- a/booster-task-graph/src/main/kotlin/com/didiglobal/booster/task/graph/GraphVariantProcessor.kt +++ b/booster-task-graph/src/main/kotlin/com/didiglobal/booster/task/graph/GraphVariantProcessor.kt @@ -1,7 +1,6 @@ package com.didiglobal.booster.task.graph import com.android.build.api.variant.Variant -import com.didiglobal.booster.gradle.getTaskName import com.didiglobal.booster.gradle.project import com.didiglobal.booster.gradle.registerTask import com.didiglobal.booster.graph.Edge