From 1e888494eeffb37c02356774382553cdbb29d4fb Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 5 Jun 2023 02:16:57 +0530 Subject: [PATCH] fix(build): temporarily revert to AGP 8.0.x Android Studio's canary version is going through some trouble recognizing test sources --- .github/workflows/baseline-profile.yml | 2 +- .../claw/gradle/AndroidCommonPlugin.kt | 5 ++- common/build.gradle.kts | 4 +-- gradle.properties | 33 ++++++++++++++----- gradle/libs.versions.toml | 2 +- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.github/workflows/baseline-profile.yml b/.github/workflows/baseline-profile.yml index 74ba0c81..6bb5aa9a 100644 --- a/.github/workflows/baseline-profile.yml +++ b/.github/workflows/baseline-profile.yml @@ -86,7 +86,7 @@ jobs: # Pull down any changes which may have been committed while this workflow has been running git pull # Sort the baseline profile, output to android/ - sort -o android/src/main/baseline-prof.txt benchmark/build/outputs/managed_device_android_test_additional_output/benchmark/api31/BaselineProfileGenerator_generateBaselineProfile-baseline-prof.txt + sort -o android/src/main/baseline-prof.txt benchmark/build/outputs/managed_device_android_test_additional_output/api31/BaselineProfileGenerator_generateBaselineProfile-baseline-prof.txt # If the baseline profile has changed, commit it if [[ $(git diff --stat android/src/main/baseline-prof.txt) != '' ]]; then git add android/src/main/baseline-prof.txt diff --git a/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt b/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt index 5a760efc..6158610c 100644 --- a/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt +++ b/build-logic/src/main/kotlin/dev/msfjarvis/claw/gradle/AndroidCommonPlugin.kt @@ -11,7 +11,6 @@ package dev.msfjarvis.claw.gradle import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.LibraryExtension import com.android.build.api.variant.ApplicationAndroidComponentsExtension -import com.android.build.api.variant.HasUnitTestBuilder import com.android.build.api.variant.LibraryAndroidComponentsExtension import com.android.build.gradle.BaseExtension import dev.msfjarvis.claw.gradle.LintConfig.configureLint @@ -74,7 +73,7 @@ private fun Project.configureSlimTests() { // Disable unit test tasks on the release build type for Android Library projects extensions.findByType()?.run { beforeVariants(selector().withBuildType("release")) { - (it as HasUnitTestBuilder).enableUnitTest = false + it.enableUnitTest = false it.enableAndroidTest = false } } @@ -82,7 +81,7 @@ private fun Project.configureSlimTests() { // Disable unit test tasks on the release build type for Android Application projects. extensions.findByType()?.run { beforeVariants(selector().withBuildType("release")) { - (it as HasUnitTestBuilder).enableUnitTest = false + it.enableUnitTest = false it.enableAndroidTest = false } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index f77e8fb8..648850e0 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -6,8 +6,6 @@ */ @file:Suppress("UnstableApiUsage") -import com.android.build.api.variant.HasUnitTestBuilder - plugins { id("dev.msfjarvis.claw.android-library") id("dev.msfjarvis.claw.kotlin-android") @@ -27,7 +25,7 @@ android { namespace = "dev.msfjarvis.claw.common" } -androidComponents { beforeVariants { (it as HasUnitTestBuilder).enableUnitTest = false } } +androidComponents { beforeVariants { it.enableUnitTest = false } } anvil { generateDaggerFactories.set(true) } diff --git a/gradle.properties b/gradle.properties index d494225a..e073d9ba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,6 +25,9 @@ kapt.incremental.apt=true # Turn off AP discovery in compile path to enable compile avoidance kapt.include.compile.classpath=false +# Force disable testOnly flag in manifest +android.injected.testOnly=false + # New incremental compilation for Kotlin kotlin.incremental.useClasspathSnapshot=true kotlin.build.report.output=file @@ -32,23 +35,35 @@ kotlin.build.report.output=file # Enable AndroidX android.useAndroidX=true -# Disable mostly unused default Android build features +# Enable non-transitive R class namespacing where each library only contains +# references to the resources it declares instead of declarations plus all +# transitive dependency references. +android.nonTransitiveRClass=true + +# Only keep the single relevant constructor for types mentioned in XML files +# instead of using a parameter wildcard which keeps them all. +android.useMinimalKeepRules=true + +# Default Android build features +android.defaults.buildfeatures.buildconfig=false +android.defaults.buildfeatures.aidl=false +android.defaults.buildfeatures.renderscript=false android.defaults.buildfeatures.resvalues=false android.defaults.buildfeatures.shaders=false -android.library.defaults.buildfeatures.androidresources=false -# Disallow resolution of dependencies at configuration time -android.dependencyResolutionAtConfigurationTime.disallow=true - -# Disallow parsing the manifest too early in the build process +# Experimental features android.disableEarlyManifestParsing=true +android.enablePartialRIncrementalBuilds=true +android.experimental.testOptions.uninstallIncompatibleApks=true +android.enableBuildConfigAsBytecode=true +android.experimental.enableNewResourceShrinker.preciseShrinking=true -# Disable warnings about unsupported features -android.suppressUnsupportedOptionWarnings=android.dependencyResolutionAtConfigurationTime.disallow,android.disableEarlyManifestParsing,android.suppressUnsupportedOptionWarnings +# Disable warnings about unsupported features, we know what we're doing +android.suppressUnsupportedOptionWarnings=android.disableEarlyManifestParsing,android.enablePartialRIncrementalBuilds,android.experimental.testOptions.uninstallIncompatibleApks,android.enableBuildConfigAsBytecode,android.experimental.enableNewResourceShrinker.preciseShrinking,android.suppressUnsupportedOptionWarnings # Add opens for KAPT # https://youtrack.jetbrains.com/issue/KT-45545#focus=Comments-27-4862682.0-0 -org.gradle.jvmargs=-Dfile.encoding=UTF-8 \ +org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 \ --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \ --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8992fe47..7c89eb81 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] accompanist = "0.31.3-beta" -agp = "8.2.0-alpha06" +agp = "8.0.2" coil = "2.4.0" # @keep used for kotlinCompilerExtensionVersion composeCompiler = "1.4.4"