diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a63b045..21df66e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,12 @@ jobs: build: name: ${{ matrix.job }} / AGP ${{ matrix.agp }} # Use macOS for emulator hardware acceleration - runs-on: 'macOS-latest' + runs-on: 'ubuntu-latest' timeout-minutes: 30 strategy: fail-fast: false # We want to see all results matrix: - agp: ['8.1.2', '8.2.0-beta06', '8.3.0-alpha07'] + agp: ['8.4.0', '8.5.0-alpha08'] job: ['instrumentation', 'plugin'] env: DEP_OVERRIDE_agp: ${{ matrix.agp }} @@ -34,30 +34,29 @@ jobs: uses: actions/checkout@v4 - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1 + uses: gradle/actions/wrapper-validation@v3 - name: Install JDK uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '20' + java-version: '21' - name: Spot check run: ./gradlew spotlessCheck + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + - name: Test plugin id: gradle if: matrix.job == 'plugin' - uses: gradle/gradle-build-action@v2 - with: - arguments: -p keeper-gradle-plugin check + run: ./gradlew -p keeper-gradle-plugin check - name: Assemble instrumentation tests id: gradle-assemble-instrumentation if: matrix.job == 'instrumentation' - uses: gradle/gradle-build-action@v2 - with: - arguments: :sample:minifyExternalStagingWithR8 validateL8 --stacktrace + run: ./gradlew :sample:minifyExternalStagingWithR8 validateL8 --stacktrace # TODO AVD caching disabled due to https://github.com/ReactiveCircus/android-emulator-runner/issues/278 # - name: AVD cache @@ -130,14 +129,10 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '20' + java-version: '21' - # Just here to restore cache - - name: Gradle prep - id: gradle - uses: gradle/gradle-build-action@v2 - with: - arguments: help + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Upload snapshot (main only) env: diff --git a/build.gradle.kts b/build.gradle.kts index d89f3985..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) } } @@ -74,7 +74,7 @@ spotless { endWithNewline() licenseHeaderFile( "spotless/copyright.kt", - "(import|plugins|buildscript|dependencies|dependencyResolutionManagement|pluginManagement|rootProject)" + "(import|plugins|buildscript|dependencies|dependencyResolutionManagement|pluginManagement|rootProject)", ) } java { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6ddcbb8e..9410079f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,32 +1,32 @@ [versions] -agp = "8.1.2" -androidx-test = "1.6.0-alpha04" -kotlin = "1.9.10" -gjf = "1.18.1" -ktfmt = "0.46" +agp = "8.4.0" +androidx-test = "1.6.0-alpha07" +kotlin = "1.9.23" +gjf = "1.22.0" +ktfmt = "0.49" [plugins] agp-library = { id = "com.android.library", version.ref = "agp" } binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.13.2" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.25.3" } -spotless = { id = "com.diffplug.spotless", version = "6.22.0" } +mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.28.0" } +spotless = { id = "com.diffplug.spotless", version = "6.25.0" } [libraries] -androidx-annotation = "androidx.annotation:annotation:1.7.0" -androidx-test-orchestrator = "androidx.test:orchestrator:1.5.0-alpha01" -androidx-test-rules = { module = "androidx.test:rules", version = "1.6.0-alpha01" } +androidx-annotation = "androidx.annotation:annotation:1.7.1" +androidx-test-orchestrator = "androidx.test:orchestrator:1.5.0-alpha04" +androidx-test-rules = { module = "androidx.test:rules", version = "1.6.0-alpha04" } androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test" } androidx-test-truth = "androidx.test.ext:junit:1.1.5" agp = { module = "com.android.tools.build:gradle", version.ref = "agp" } -desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.0.3" +desugarJdkLibs = "com.android.tools:desugar_jdk_libs:2.0.4" javapoet = "com.squareup:javapoet:1.13.0" junit = "junit:junit:4.13.2" kgp = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kgp-api = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin-api", version.ref = "kotlin" } -kotlinpoet = "com.squareup:kotlinpoet:1.14.2" -okio = "com.squareup.okio:okio:3.6.0" -truth = "com.google.truth:truth:1.1.5" +kotlinpoet = "com.squareup:kotlinpoet:1.16.0" +okio = "com.squareup.okio:okio:3.9.0" +truth = "com.google.truth:truth:1.4.2" zipflinger = { module = "com.android:zipflinger", version.ref = "agp" } renovateTrigger-gjf = { module = "com.google.googlejavaformat:google-java-format", version.ref = "gjf" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c..e6441136 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f862..b82aa23a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 93e3f59f..25da30db 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/keeper-gradle-plugin/build.gradle.kts b/keeper-gradle-plugin/build.gradle.kts index 337b23aa..fd3b6e5d 100644 --- a/keeper-gradle-plugin/build.gradle.kts +++ b/keeper-gradle-plugin/build.gradle.kts @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version libs.versions.kotlin.get() `java-gradle-plugin` - id("org.jetbrains.dokka") version "1.8.20" + id("org.jetbrains.dokka") version "1.9.20" alias(libs.plugins.mavenPublish) alias(libs.plugins.binaryCompatibilityValidator) id("org.jetbrains.kotlin.plugin.sam.with.receiver") version libs.versions.kotlin.get() @@ -35,8 +35,8 @@ tasks.withType().configureEach { compilerOptions { jvmTarget.set(JvmTarget.JVM_17) // Match AGP's requirement // Because Gradle's Kotlin handling is stupid, this falls out of date quickly - apiVersion.set(KotlinVersion.KOTLIN_1_8) - languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_9) + languageVersion.set(KotlinVersion.KOTLIN_1_9) // freeCompilerArgs.add(listOf("-progressive")) // We use class SAM conversions because lambdas compiled into invokedynamic are not // Serializable, which causes accidental headaches with Gradle configuration caching. It's @@ -65,7 +65,7 @@ sourceSets { getByName("test").resources.srcDirs(project.layout.buildDirectory.dir("pluginUnderTestMetadata")) } -java { toolchain { languageVersion.set(JavaLanguageVersion.of(20)) } } +java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } } tasks.withType().configureEach { options.release.set(17) } diff --git a/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.jar index 7f93135c..e6441136 100644 Binary files a/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.jar and b/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.properties index 3fa8f862..b82aa23a 100644 --- a/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/keeper-gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/keeper-gradle-plugin/gradlew.bat b/keeper-gradle-plugin/gradlew.bat index 93e3f59f..25da30db 100644 --- a/keeper-gradle-plugin/gradlew.bat +++ b/keeper-gradle-plugin/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/keeper-gradle-plugin/src/main/java/com/slack/keeper/InferAndroidTestKeepRules.kt b/keeper-gradle-plugin/src/main/java/com/slack/keeper/InferAndroidTestKeepRules.kt index 50078224..9f9f5bbc 100644 --- a/keeper-gradle-plugin/src/main/java/com/slack/keeper/InferAndroidTestKeepRules.kt +++ b/keeper-gradle-plugin/src/main/java/com/slack/keeper/InferAndroidTestKeepRules.kt @@ -117,7 +117,7 @@ constructor(private val execOps: ExecOperations) : DefaultTask() { "--lib" to androidTestJar.get().asFile.takeIf { it.exists() }?.absolutePath, "--target" to appTargetJar.get().asFile.absolutePath, "--source" to androidTestSourceJar.get().asFile.absolutePath, - "--output" to outputProguardRules.get().asFile.absolutePath + "--output" to outputProguardRules.get().asFile.absolutePath, ) .map { if (it.second != null) listOf(it.first, it.second) else listOf() } .reduce { acc, any -> acc + any } @@ -136,7 +136,7 @@ constructor(private val execOps: ExecOperations) : DefaultTask() { enableAssertions: Property, extensionJvmArgs: ListProperty, traceReferencesArgs: ListProperty, - r8Configuration: Configuration + r8Configuration: Configuration, ): InferAndroidTestKeepRules.() -> Unit = { if (automaticallyAddR8Repo.get()) { // This is the maven repo where r8 tagged releases are hosted. Only the r8 artifact is 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 4927c87a..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 @@ -41,7 +37,6 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.UnknownTaskException import org.gradle.api.artifacts.Configuration -import org.gradle.api.file.Directory import org.gradle.api.file.FileCollection import org.gradle.api.file.RegularFile import org.gradle.api.provider.Provider @@ -149,7 +144,7 @@ public class KeeperPlugin : Plugin { project: Project, appExtension: AppExtension, appComponentsExtension: ApplicationAndroidComponentsExtension, - extension: KeeperExtension + extension: KeeperExtension, ) { appComponentsExtension.onApplicableVariants(project, verifyMinification = false) { testVariant, @@ -221,7 +216,7 @@ public class KeeperPlugin : Plugin { private fun Project.configureKeepRulesGeneration( appExtension: AppExtension, appComponentsExtension: ApplicationAndroidComponentsExtension, - extension: KeeperExtension + extension: KeeperExtension, ) { // Set up r8 configuration val r8Configuration = @@ -243,7 +238,7 @@ public class KeeperPlugin : Plugin { appExtension, appComponentsExtension, "android.jar", - checkIfExisting = true + checkIfExisting = true, ) } ) @@ -254,7 +249,7 @@ public class KeeperPlugin : Plugin { appExtension, appComponentsExtension, "optional/android.test.base.jar", - checkIfExisting = false + checkIfExisting = false, ) } ) @@ -265,13 +260,13 @@ public class KeeperPlugin : Plugin { val intermediateAppJar = createIntermediateAppJar( appVariant = appVariant, - emitDebugInfo = extension.emitDebugInformation + emitDebugInfo = extension.emitDebugInformation, ) val intermediateAndroidTestJar = createIntermediateAndroidTestJar( emitDebugInfo = extension.emitDebugInformation, testVariant = testVariant, - appJarsProvider = intermediateAppJar.flatMap { it.appJarsFile } + appJarsProvider = intermediateAppJar.flatMap { it.appJarsFile }, ) val inferAndroidTestUsageProvider = tasks.register( @@ -287,44 +282,20 @@ public class KeeperPlugin : Plugin { enableAssertions = extension.enableAssertions, extensionJvmArgs = extension.r8JvmArgs, traceReferencesArgs = extension.traceReferences.arguments, - r8Configuration = r8Configuration - ) + r8Configuration = r8Configuration, + ), ) - val prop = - layout.dir(inferAndroidTestUsageProvider.flatMap { it.outputProguardRules.asFile }) + val prop = layout.dir(inferAndroidTestUsageProvider.flatMap { it.outputProguardRules.asFile }) 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") } } @@ -332,7 +303,7 @@ public class KeeperPlugin : Plugin { appExtension: AppExtension, appComponentsExtension: ApplicationAndroidComponentsExtension, path: String, - checkIfExisting: Boolean + checkIfExisting: Boolean, ): File { val compileSdkVersion = appExtension.compileSdkVersion ?: error("No compileSdkVersion found") val file = @@ -348,7 +319,7 @@ public class KeeperPlugin : Plugin { private fun ApplicationAndroidComponentsExtension.onApplicableVariants( project: Project, verifyMinification: Boolean, - body: (AndroidTest, ApplicationVariant) -> Unit + body: (AndroidTest, ApplicationVariant) -> Unit, ) { onVariants { appVariant -> val buildType = appVariant.buildType ?: return@onVariants @@ -372,16 +343,10 @@ public class KeeperPlugin : Plugin { } } - private fun Project.configureR8Task( - appVariant: String, - action: R8Task.() -> Unit, - ) { + private fun Project.configureR8Task(appVariant: String, action: R8Task.() -> Unit) { val targetName = interpolateR8TaskName(appVariant) - tasks - .withType(R8Task::class.java) - .matching { it.name == targetName } - .configureEach(action) + tasks.withType(R8Task::class.java).matching { it.name == targetName }.configureEach(action) } /** @@ -391,12 +356,12 @@ public class KeeperPlugin : Plugin { private fun Project.createIntermediateAndroidTestJar( emitDebugInfo: Provider, testVariant: AndroidTest, - appJarsProvider: Provider + appJarsProvider: Provider, ): TaskProvider { val taskProvider = tasks.register( "jar${testVariant.name.capitalize(Locale.US)}ClassesForKeeper", - AndroidTestVariantClasspathJar::class.java + AndroidTestVariantClasspathJar::class.java, ) { this.emitDebugInfo.value(emitDebugInfo) this.appJarsFile.set(appJarsProvider) @@ -414,7 +379,7 @@ public class KeeperPlugin : Plugin { private fun wireClassesAndJarsFor( component: Component, - taskProvider: TaskProvider + taskProvider: TaskProvider, ) { component.artifacts .forScope(ScopedArtifacts.Scope.ALL) @@ -428,12 +393,12 @@ public class KeeperPlugin : Plugin { */ private fun Project.createIntermediateAppJar( appVariant: ApplicationVariant, - emitDebugInfo: Provider + emitDebugInfo: Provider, ): TaskProvider { val taskProvider = tasks.register( "jar${appVariant.name.capitalize(Locale.US)}ClassesForKeeper", - VariantClasspathJar::class.java + VariantClasspathJar::class.java, ) { this.emitDebugInfo.set(emitDebugInfo) @@ -486,7 +451,7 @@ internal fun String.capitalize(locale: Locale): String { */ private inline fun Project.namedLazy( targetName: String, - crossinline action: (TaskProvider) -> Unit + crossinline action: (TaskProvider) -> Unit, ) { try { action(tasks.named(targetName, T::class.java)) 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/JavaPoetExt.kt b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/JavaPoetExt.kt index 1472ccf4..2869fcea 100644 --- a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/JavaPoetExt.kt +++ b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/JavaPoetExt.kt @@ -23,11 +23,11 @@ import javax.lang.model.element.Modifier.PUBLIC internal fun javaFile( packageName: String, className: String, - body: TypeSpec.Builder.() -> Unit + body: TypeSpec.Builder.() -> Unit, ): SourceFile { return JavaFile.builder( packageName, - TypeSpec.classBuilder(className).addModifiers(PUBLIC).apply(body).build() + TypeSpec.classBuilder(className).addModifiers(PUBLIC).apply(body).build(), ) .build() .asSourceFile() 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 a2592e50..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 @@ -89,8 +89,8 @@ internal class KeeperFunctionalTest { buildGradleFile( "staging", "external", - keeperExtraConfig = KeeperExtraConfig.TRACE_REFERENCES_ENABLED - ) + keeperExtraConfig = KeeperExtraConfig.TRACE_REFERENCES_ENABLED, + ), ) val result = projectDir.runAsWiredStaging() @@ -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") @@ -139,8 +139,8 @@ internal class KeeperFunctionalTest { buildGradleFile( "release", "external", - androidExtraConfig = AndroidExtraConfig.ONLY_INTERNAL_RELEASE - ) + androidExtraConfig = AndroidExtraConfig.ONLY_INTERNAL_RELEASE, + ), ) val result = @@ -151,7 +151,7 @@ internal class KeeperFunctionalTest { "-x", "lintVitalExternalRelease", "-x", - "lintVitalInternalRelease" + "lintVitalInternalRelease", ) assertThat(result.findTask("jarExternalReleaseAndroidTestClassesForKeeper")).isNull() assertThat(result.findTask("jarExternalReleaseClassesForKeeper")).isNull() @@ -175,8 +175,8 @@ internal class KeeperFunctionalTest { buildGradleFile( "debug", "internal", - androidExtraConfig = AndroidExtraConfig.ONLY_INTERNAL_DEBUG - ) + androidExtraConfig = AndroidExtraConfig.ONLY_INTERNAL_DEBUG, + ), ) val result = runGradle(projectDir, "assembleInternalDebug") @@ -209,8 +209,8 @@ internal class KeeperFunctionalTest { extraDependencies = mapOf( "implementation" to "\"org.threeten:threetenbp:1.4.0:no-tzdb\"", - "androidTestImplementation" to "\"org.threeten:threetenbp:1.4.0\"" - ) + "androidTestImplementation" to "\"org.threeten:threetenbp:1.4.0\"", + ), ) val (projectDir, _) = prepareProject(temporaryFolder, buildFile) projectDir.runSingleTask("jarExternalStagingAndroidTestClassesForKeeper") @@ -285,8 +285,8 @@ private val EXPECTED_TRACE_REFERENCES_CONFIG: Map?> = "-keep class com.slack.keeper.sample.TestOnlyKotlinClass" to listOf( "public void testOnlyMethod();", - "com.slack.keeper.sample.TestOnlyKotlinClass INSTANCE;" - ) + "com.slack.keeper.sample.TestOnlyKotlinClass INSTANCE;", + ), ) private fun indentRules(header: String, content: List?) = @@ -315,7 +315,7 @@ internal enum class KeeperExtraConfig(val groovy: String) { traceReferences {} """ .trimIndent() - ) + ), } internal enum class AndroidExtraConfig(val groovy: String) { @@ -363,7 +363,7 @@ internal enum class AndroidExtraConfig(val groovy: String) { } """ .trimIndent() - ) + ), } @Language("groovy") @@ -374,7 +374,7 @@ private fun buildGradleFile( keeperExtraConfig: KeeperExtraConfig = KeeperExtraConfig.NONE, androidExtraConfig: AndroidExtraConfig = AndroidExtraConfig.ONLY_EXTERNAL_STAGING, emitDebugInformation: Boolean = true, - extraDependencies: Map = emptyMap() + extraDependencies: Map = emptyMap(), ): String { val testVariant = "$testFlavor${testBuildType.capitalize(Locale.US)}" @Suppress("UnnecessaryVariable") @@ -394,12 +394,12 @@ private fun buildGradleFile( } plugins { - id 'com.android.application' version '8.1.2' - id 'org.jetbrains.kotlin.android' version '1.9.10' + id 'com.android.application' version '8.4.0' + id 'org.jetbrains.kotlin.android' version '1.9.23' id 'com.slack.keeper' } - java { toolchain { languageVersion.set(JavaLanguageVersion.of(20)) } } + java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } } tasks.withType(KotlinCompile).configureEach { compilerOptions { jvmTarget.set(JvmTarget.JVM_11) } } @@ -503,7 +503,7 @@ private val MAIN_SOURCES = addStatement("super.onCreate()") addStatement( "\$T.applicationCalledMethod()", - ClassName.get("com.slack.keeper.sample", "ApplicationUsedClass") + ClassName.get("com.slack.keeper.sample", "ApplicationUsedClass"), ) } }, @@ -526,7 +526,7 @@ private val MAIN_SOURCES = addModifiers(STATIC) addComment("This class and method are completely unused") } - } + }, ) private val ANDROID_TEST_SOURCES = @@ -536,7 +536,7 @@ private val ANDROID_TEST_SOURCES = methodSpec("callTestOnlyMethod") { addStatement( "\$T.testOnlyMethod()", - ClassName.get("com.slack.keeper.sample", "TestOnlyClass") + ClassName.get("com.slack.keeper.sample", "TestOnlyClass"), ) } }, @@ -545,10 +545,10 @@ private val ANDROID_TEST_SOURCES = funSpec("callTestOnlyMethod") { addStatement( "%T.testOnlyMethod()", - KpClassName("com.slack.keeper.sample", "TestOnlyKotlinClass") + KpClassName("com.slack.keeper.sample", "TestOnlyKotlinClass"), ) } - } + }, ) // We include Unit.class here because that allows us to also test that App's transitive dependencies diff --git a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KotlinPoetExt.kt b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KotlinPoetExt.kt index 5767cd11..7b50bb32 100644 --- a/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KotlinPoetExt.kt +++ b/keeper-gradle-plugin/src/test/kotlin/com/slack/keeper/KotlinPoetExt.kt @@ -23,11 +23,11 @@ import java.io.File internal fun kotlinFile( packageName: String, className: String, - body: TypeSpec.Builder.() -> Unit + body: TypeSpec.Builder.() -> Unit, ): SourceFile { return FileSpec.get( packageName = packageName, - typeSpec = TypeSpec.objectBuilder(className).apply(body).build() + typeSpec = TypeSpec.objectBuilder(className).apply(body).build(), ) .asSourceFile() }