From f11d3cf1483422f0575339b0bfd9fecdb214681c Mon Sep 17 00:00:00 2001 From: 0xera <56160164+0xera@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:54:19 +0300 Subject: [PATCH] support binary compatibility with agp 8.6 (#10) --- .../io/deepmedia/tools/grease/GreasePlugin.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt b/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt index 3af5679..71b99a9 100644 --- a/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt +++ b/grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt @@ -9,7 +9,6 @@ import com.android.build.gradle.internal.LibraryTaskManager import com.android.build.gradle.internal.LoggerWrapper import com.android.build.gradle.internal.TaskManager import com.android.build.gradle.internal.component.ComponentCreationConfig -import com.android.build.gradle.internal.manifest.parseManifest import com.android.build.gradle.internal.publishing.AndroidArtifacts import com.android.build.gradle.internal.res.GenerateLibraryRFileTask import com.android.build.gradle.internal.res.ParseLibraryResourcesTask @@ -23,11 +22,11 @@ import com.android.build.gradle.internal.tasks.manifest.mergeManifests import com.android.build.gradle.tasks.BundleAar import com.android.build.gradle.tasks.MergeResources import com.android.build.gradle.tasks.ProcessLibraryManifest -import com.android.builder.errors.DefaultIssueReporter import com.android.ide.common.resources.CopyToOutputDirectoryResourceCompilationService +import com.android.ide.common.symbols.parseManifest import com.android.manifmerger.ManifestMerger2 import com.android.manifmerger.ManifestProvider -import com.android.utils.StdLogger +import com.android.utils.appendCapitalized import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.gradle.api.Plugin @@ -50,8 +49,6 @@ import java.io.File */ open class GreasePlugin : Plugin { - private val defaultIssueReporter = DefaultIssueReporter(StdLogger(StdLogger.Level.WARNING)) - override fun apply(target: Project) { target.plugins.withId("com.android.library") { val log = Logger(target, "grease") @@ -469,8 +466,8 @@ open class GreasePlugin : Plugin { log.d { "Executing shadowing for variant ${variant.name} and ${extraManifests.files.size} roots with namespace ${variant.namespace.get()}..." } extraManifests.forEach { inputFile -> - val manifestData = parseManifest(inputFile, true, { true }, defaultIssueReporter) - manifestData.packageName?.let { fromPackageName -> + val manifestData = parseManifest(inputFile) + manifestData.`package`?.let { fromPackageName -> log.d { "Processing R class from $fromPackageName manifestInput=${inputFile.path} outputDir=${compileTask.get().destinationDirectory.get()}..." } relocate(RClassRelocator(fromPackageName, variant.namespace.get(), log)) } @@ -664,6 +661,9 @@ open class GreasePlugin : Plugin { } } +private fun ComponentCreationConfig.computeTaskName(prefix: String, suffix: String): String = + prefix.appendCapitalized(name, suffix) + private fun Variant.componentCreationConfigOrThrow(): ComponentCreationConfig { return when (this) { is ComponentCreationConfig -> this