From 1550a19dc3712561f2c4f207d066c7ca917cb8eb Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Wed, 8 May 2024 19:43:29 -0700 Subject: [PATCH] Try updating to fix main more (#142) * Update to fix main * Update toolchain for libraries to 21 --- build.gradle.kts | 2 +- .../java/com/slack/keeper/KeeperPlugin.kt | 35 +++---------------- .../src/test/kotlin/com/slack/keeper/Files.kt | 4 ++- .../com/slack/keeper/KeeperFunctionalTest.kt | 2 +- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index aee7dacd..59cdfe9f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,7 +27,7 @@ plugins { subprojects { pluginManager.withPlugin("java") { - configure { toolchain { languageVersion.set(JavaLanguageVersion.of(20)) } } + configure { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } } tasks.withType().configureEach { options.release.set(11) } } diff --git a/keeper-gradle-plugin/src/main/java/com/slack/keeper/KeeperPlugin.kt b/keeper-gradle-plugin/src/main/java/com/slack/keeper/KeeperPlugin.kt index 60ac7b70..bc1a5986 100644 --- a/keeper-gradle-plugin/src/main/java/com/slack/keeper/KeeperPlugin.kt +++ b/keeper-gradle-plugin/src/main/java/com/slack/keeper/KeeperPlugin.kt @@ -17,10 +17,7 @@ package com.slack.keeper -import com.android.build.api.artifact.Artifacts import com.android.build.api.artifact.ScopedArtifact -import com.android.build.api.artifact.impl.ArtifactsImpl -import com.android.build.api.component.analytics.AnalyticsEnabledArtifacts import com.android.build.api.variant.AndroidTest import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.ApplicationVariant @@ -29,7 +26,6 @@ import com.android.build.api.variant.ScopedArtifacts import com.android.build.gradle.AppExtension import com.android.build.gradle.internal.publishing.AndroidArtifacts import com.android.build.gradle.internal.publishing.AndroidArtifacts.ArtifactType -import com.android.build.gradle.internal.scope.InternalArtifactType import com.android.build.gradle.internal.tasks.L8DexDesugarLibTask import com.android.build.gradle.internal.tasks.R8Task import java.io.File @@ -295,34 +291,11 @@ public class KeeperPlugin : Plugin { configureR8Task(appVariant.name) { logger.debug("$TAG: Patching task '$name' with inferred androidTest proguard rules") configurationFiles.from(prop) + configurationFiles.from( + project.provider { testVariant.runtimeConfiguration.proguardFiles() } + ) + configurationFiles.from(testVariant.proguardFiles) } - - val disableTestProguardFiles = project.hasProperty("keeper.disableTestProguardFiles") - - if (!disableTestProguardFiles) { - // We offer an option to disable this because the FILTERED_PROGUARD_RULES doesn't - // propagate - // task dependencies and breaks in Gradle 8. - afterEvaluate { - val testProguardFiles = - project.provider { testVariant.runtimeConfiguration.proguardFiles() } - val testProguardFile = - (testVariant.artifacts.unwrap()).get(InternalArtifactType.GENERATED_PROGUARD_FILE) - configureR8Task(appVariant.name) { - logger.debug("$TAG: Patching task '$name' with test-specific proguard rules") - configurationFiles.from(testProguardFiles) - configurationFiles.from(testProguardFile) - } - } - } - } - } - - private fun Artifacts.unwrap(): ArtifactsImpl { - return when (this) { - is ArtifactsImpl -> this - is AnalyticsEnabledArtifacts -> delegate.unwrap() - else -> error("Unrecognized artifacts type $javaClass") } } diff --git a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/Files.kt b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/Files.kt index 0d36f3d7..32b6d39b 100644 --- a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/Files.kt +++ b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/Files.kt @@ -67,7 +67,9 @@ internal sealed class SourceFile(val name: String) { data class KotlinSourceFile(val fileSpec: FileSpec) : SourceFile(fileSpec.members.filterIsInstance().first().name!!) { - override fun writeTo(file: File) = fileSpec.writeTo(file) + override fun writeTo(file: File) { + fileSpec.writeTo(file) + } } } diff --git a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KeeperFunctionalTest.kt b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KeeperFunctionalTest.kt index 17cf9aec..92521a02 100644 --- a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KeeperFunctionalTest.kt +++ b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KeeperFunctionalTest.kt @@ -115,7 +115,7 @@ internal class KeeperFunctionalTest { // Assert we correctly generated rules val generatedRules = - projectDir.generatedChild("externalStagingAndroidTest/inferredKeepRules.pro") + projectDir.generatedChild("ExternalStagingAndroidTest/inferredKeepRules.pro") assertThat(generatedRules.readText().trim()) .isEqualTo( EXPECTED_TRACE_REFERENCES_CONFIG.map { indentRules(it.key, it.value) }.joinToString("\n")