From 4c64a05897da6b6c534f2ed2599836c574a5cf63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= Date: Fri, 16 Sep 2022 13:39:55 +0200 Subject: [PATCH] Update to AGP 7.3.0 stable Enables Gradle configuration cache. Fix "no name set for build-config" warning. Fix printing of test APKs due to AGP 7.3 changes Change-Id: I65ec0cb9eba3d047417fc512ffeb66d378ba0c75 --- .github/workflows/Build.yaml | 2 +- .../samples/apps/nowinandroid/PrintTestApks.kt | 14 ++++++++++++-- build-logic/settings.gradle.kts | 1 + gradle.properties | 4 ++-- gradle/libs.versions.toml | 2 +- tools/pre-push | 2 +- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Build.yaml b/.github/workflows/Build.yaml index 595a0dc6e..c610772b8 100644 --- a/.github/workflows/Build.yaml +++ b/.github/workflows/Build.yaml @@ -34,7 +34,7 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Check spotless - run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --stacktrace + run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace - name: Check lint run: ./gradlew lintDebug --stacktrace diff --git a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/PrintTestApks.kt b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/PrintTestApks.kt index 1a9b3c7ed..6c08216cc 100644 --- a/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/PrintTestApks.kt +++ b/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/PrintTestApks.kt @@ -38,7 +38,15 @@ internal fun Project.configurePrintApksTask(extension: AndroidComponentsExtensio if (variant is HasAndroidTest) { val loader = variant.artifacts.getBuiltArtifactsLoader() val artifact = variant.androidTest?.artifacts?.get(SingleArtifact.APK) - val testSources = variant.androidTest?.sources?.java?.all + val javaSources = variant.androidTest?.sources?.java?.all + val kotlinSources = variant.androidTest?.sources?.kotlin?.all + + val testSources = if (javaSources != null && kotlinSources != null) { + javaSources.zip(kotlinSources) { javaDirs, kotlinDirs -> + javaDirs + kotlinDirs + } + } else javaSources ?: kotlinSources + if (artifact != null && testSources != null) { tasks.register( "${variant.name}PrintTestApk", @@ -70,7 +78,9 @@ internal abstract class PrintApkLocationTask : DefaultTask() { @TaskAction fun taskAction() { val hasFiles = sources.orNull?.any { directory -> - directory.asFileTree.files.any { it.isFile } + directory.asFileTree.files.any { + it.isFile && it.parentFile.path.contains("build${File.separator}generated").not() + } } ?: throw RuntimeException("Cannot check androidTest sources") // Don't print APK location if there are no androidTest source files diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index b5a0552a2..e0e373ae6 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -28,4 +28,5 @@ dependencyResolutionManagement { } } +rootProject.name = "build-logic" include(":convention") diff --git a/gradle.properties b/gradle.properties index 5643db706..6533378ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,8 +21,8 @@ org.gradle.configureondemand=false # Enable caching between builds. org.gradle.caching=true -# TODO: enable this when moving to AGP 7.3 -#org.gradle.unsafe.configuration-cache=true +# Enable configuration caching between builds. +org.gradle.unsafe.configuration-cache=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app"s APK diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 949f1a643..0a181d023 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] accompanist = "0.24.8-beta" androidDesugarJdkLibs = "1.1.5" -androidGradlePlugin = "7.2.2" # TODO: when changing this to 7.3 resolve TODO in gradle.properties +androidGradlePlugin = "7.3.0" androidxActivity = "1.5.1" androidxAppCompat = "1.5.1" androidxCompose = "1.3.0-beta02" diff --git a/tools/pre-push b/tools/pre-push index cadcda472..81157f9ca 100644 --- a/tools/pre-push +++ b/tools/pre-push @@ -88,7 +88,7 @@ done if [[ -n "$run_checks" ]]; then # pre-push usually executes in the repository root, but just to be safe... cd "$(git rev-parse --show-toplevel)" - ./gradlew --init-script gradle/init.gradle.kts check + ./gradlew --init-script gradle/init.gradle.kts --no-configuration-cache check exit $? fi