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

Try updating to fix main more #142

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugins {

subprojects {
pluginManager.withPlugin("java") {
configure<JavaPluginExtension> { toolchain { languageVersion.set(JavaLanguageVersion.of(20)) } }
configure<JavaPluginExtension> { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } }

tasks.withType<JavaCompile>().configureEach { options.release.set(11) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -295,34 +291,11 @@ public class KeeperPlugin : Plugin<Project> {
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")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ internal sealed class SourceFile(val name: String) {

data class KotlinSourceFile(val fileSpec: FileSpec) :
SourceFile(fileSpec.members.filterIsInstance<TypeSpec>().first().name!!) {
override fun writeTo(file: File) = fileSpec.writeTo(file)
override fun writeTo(file: File) {
fileSpec.writeTo(file)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading