From adae7850bb3e96a6a6ab3b8d632bf378e7330243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Alc=C3=A9rreca?= Date: Mon, 18 Mar 2024 09:54:34 +0000 Subject: [PATCH] Adds empty tests as workaround for AGP bug Change-Id: I2fce55bfaf204e85ff326a5ce5cb31599b916dbb --- ...ndroidApplicationJacocoConventionPlugin.kt | 2 +- .../AndroidLibraryJacocoConventionPlugin.kt | 8 ++---- core/database/src/test/kotlin/EmptyTest.kt | 25 +++++++++++++++++++ core/ui/src/test/kotlin/EmptyTest.kt | 25 +++++++++++++++++++ sync/work/src/test/kotlin/EmptyTest.kt | 25 +++++++++++++++++++ 5 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 core/database/src/test/kotlin/EmptyTest.kt create mode 100644 core/ui/src/test/kotlin/EmptyTest.kt create mode 100644 sync/work/src/test/kotlin/EmptyTest.kt diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt index 1610e0ab8..8d28f99dd 100644 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt @@ -25,10 +25,10 @@ class AndroidApplicationJacocoConventionPlugin : Plugin { val androidExtension = extensions.getByType() androidExtension.buildTypes.configureEach { + // The jacoco plugin is applied automatically when any of these are set enableAndroidTestCoverage = true enableUnitTestCoverage = true } } } - } diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt index a0d08f805..9733ce6f5 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt @@ -15,7 +15,6 @@ */ import com.android.build.api.dsl.LibraryExtension -import com.android.build.api.variant.LibraryAndroidComponentsExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.getByType @@ -23,17 +22,14 @@ import org.gradle.kotlin.dsl.getByType class AndroidLibraryJacocoConventionPlugin : Plugin { override fun apply(target: Project) { with(target) { - val androidExtension: LibraryExtension = extensions.getByType() + val androidExtension = extensions.getByType() androidExtension.buildTypes.configureEach { // The jacoco plugin is applied automatically when any of these are set + enableAndroidTestCoverage = true enableUnitTestCoverage = true } - - val extension = extensions.getByType() - } } - } diff --git a/core/database/src/test/kotlin/EmptyTest.kt b/core/database/src/test/kotlin/EmptyTest.kt new file mode 100644 index 000000000..b6a1d4919 --- /dev/null +++ b/core/database/src/test/kotlin/EmptyTest.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.junit.Test + +/** + * Workaround for https://issuetracker.google.com/329869184 + */ +class EmptyTest { + @Test + fun test1() { } +} diff --git a/core/ui/src/test/kotlin/EmptyTest.kt b/core/ui/src/test/kotlin/EmptyTest.kt new file mode 100644 index 000000000..b6a1d4919 --- /dev/null +++ b/core/ui/src/test/kotlin/EmptyTest.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.junit.Test + +/** + * Workaround for https://issuetracker.google.com/329869184 + */ +class EmptyTest { + @Test + fun test1() { } +} diff --git a/sync/work/src/test/kotlin/EmptyTest.kt b/sync/work/src/test/kotlin/EmptyTest.kt new file mode 100644 index 000000000..b6a1d4919 --- /dev/null +++ b/sync/work/src/test/kotlin/EmptyTest.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.junit.Test + +/** + * Workaround for https://issuetracker.google.com/329869184 + */ +class EmptyTest { + @Test + fun test1() { } +}