Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

another attempt to fix binary compatibility issue with agp 8.6 #12

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions grease/src/main/kotlin/io/deepmedia/tools/grease/GreasePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ open class GreasePlugin : Plugin<Project> {

val componentConfig = variant.componentCreationConfigOrThrow()

target.locateTask(componentConfig.computeTaskName("process", "Manifest"))?.configure {
target.locateTask(componentConfig.resolveTaskName("process", "Manifest"))?.configure {
val processManifestTask = this as ProcessLibraryManifest

val extraManifests = configurations.artifactsOf(AndroidArtifacts.ArtifactType.MANIFEST)
Expand Down Expand Up @@ -218,7 +218,7 @@ open class GreasePlugin : Plugin<Project> {

val creationConfig = variant.componentCreationConfigOrThrow()

target.locateTask(creationConfig.computeTaskName("copy", "JniLibsProjectAndLocalJars"))?.configure {
target.locateTask(creationConfig.resolveTaskName("copy", "JniLibsProjectAndLocalJars"))?.configure {
val copyJniTask = this as LibraryJniLibsTask
val extraJniLibs = configurations.artifactsOf(AndroidArtifacts.ArtifactType.JNI)
dependsOn(extraJniLibs)
Expand Down Expand Up @@ -315,7 +315,7 @@ open class GreasePlugin : Plugin<Project> {
log.d { "Configuring variant ${variant.name}..." }
val creationConfig = variant.componentCreationConfigOrThrow()

target.locateTask(creationConfig.computeTaskName("package", "Resources"))?.configure {
target.locateTask(creationConfig.resolveTaskName("package", "Resources"))?.configure {
this as MergeResources

val resourcesMergingWorkdir = target.greaseBuildDir.get().dir(variant.name).dir("resources")
Expand Down Expand Up @@ -393,7 +393,7 @@ open class GreasePlugin : Plugin<Project> {
val bundleLibraryTask = creationConfig.taskContainer.bundleLibraryTask

val greaseExpandTask = target.tasks.locateOrRegisterTask(
creationConfig.computeTaskName("extract", "Aar").greasify(),
creationConfig.resolveTaskName("extract", "Aar").greasify(),
) {
val bundleAar = bundleLibraryTask?.get() as BundleAar

Expand All @@ -409,7 +409,7 @@ open class GreasePlugin : Plugin<Project> {
}

val greaseProcessTask = target.tasks.locateOrRegisterTask(
creationConfig.computeTaskName("process", "Jar").greasify(),
creationConfig.resolveTaskName("process", "Jar").greasify(),
) {

// There are many options here. PROCESSED_JAR, PROCESSED_AAR, CLASSES, CLASSES_JAR ...
Expand Down Expand Up @@ -440,7 +440,7 @@ open class GreasePlugin : Plugin<Project> {
}

val greaseShadowTask = target.tasks.locateOrRegisterTask(
creationConfig.computeTaskName("shadow", "Aar").greasify(),
creationConfig.resolveTaskName("shadow", "Aar").greasify(),
ShadowJar::class.java
) {
val compileTask = creationConfig.taskContainer.javacTask
Expand Down Expand Up @@ -645,7 +645,7 @@ open class GreasePlugin : Plugin<Project> {
val log = logger.child("configureVariantProguardFiles")
log.d { "Configuring variant ${variant.name}..." }
val creationConfig = variant.componentCreationConfigOrThrow()
target.locateTask(creationConfig.computeTaskName("merge", "ConsumerProguardFiles"))?.configure {
target.locateTask(creationConfig.resolveTaskName("merge", "ConsumerProguardFiles"))?.configure {
val mergeFileTask = this as MergeFileTask
// UNFILTERED_PROGUARD_RULES, FILTERED_PROGUARD_RULES, AAPT_PROGUARD_RULES, ...
// UNFILTERED_PROGUARD_RULES is output of the AarTransform. FILTERED_PROGUARD_RULES
Expand All @@ -661,7 +661,7 @@ open class GreasePlugin : Plugin<Project> {
}
}

private fun ComponentCreationConfig.computeTaskName(prefix: String, suffix: String): String =
private fun ComponentCreationConfig.resolveTaskName(prefix: String, suffix: String): String =
prefix.appendCapitalized(name, suffix)

private fun Variant.componentCreationConfigOrThrow(): ComponentCreationConfig {
Expand Down