diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ae1c0d6865..abfa7056c5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -19,7 +19,7 @@ plugins { alias(libs.plugins.nowinandroid.android.application) alias(libs.plugins.nowinandroid.android.application.compose) alias(libs.plugins.nowinandroid.android.application.flavors) - alias(libs.plugins.nowinandroid.android.application.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) alias(libs.plugins.nowinandroid.android.application.firebase) id("com.google.android.gms.oss-licenses-plugin") diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index aa0e615ade..2a1f4b76ae 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -62,10 +62,6 @@ gradlePlugin { id = "nowinandroid.android.application" implementationClass = "AndroidApplicationConventionPlugin" } - register("androidApplicationJacoco") { - id = "nowinandroid.android.application.jacoco" - implementationClass = "AndroidApplicationJacocoConventionPlugin" - } register("androidLibraryCompose") { id = "nowinandroid.android.library.compose" implementationClass = "AndroidLibraryComposeConventionPlugin" @@ -78,9 +74,9 @@ gradlePlugin { id = "nowinandroid.android.feature" implementationClass = "AndroidFeatureConventionPlugin" } - register("androidLibraryJacoco") { - id = "nowinandroid.android.library.jacoco" - implementationClass = "AndroidLibraryJacocoConventionPlugin" + register("androidJacoco") { + id = "nowinandroid.android.jacoco" + implementationClass = "AndroidJacocoConventionPlugin" } register("androidTest") { id = "nowinandroid.android.test" diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt deleted file mode 100644 index ac385b0d97..0000000000 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationJacocoConventionPlugin.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 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 com.android.build.api.variant.ApplicationAndroidComponentsExtension -import com.android.build.gradle.internal.dsl.BaseAppModuleExtension -import com.google.samples.apps.nowinandroid.configureJacoco -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.getByType - -class AndroidApplicationJacocoConventionPlugin : Plugin { - override fun apply(target: Project) { - with(target) { - pluginManager.apply("jacoco") - val androidExtension = extensions.getByType() - - androidExtension.buildTypes.configureEach { - enableAndroidTestCoverage = true - enableUnitTestCoverage = true - } - - configureJacoco(extensions.getByType()) - } - } -} diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidJacocoConventionPlugin.kt similarity index 54% rename from build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt rename to build-logic/convention/src/main/kotlin/AndroidJacocoConventionPlugin.kt index 6f2ff60c5a..4c25fb845c 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryJacocoConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidJacocoConventionPlugin.kt @@ -17,23 +17,36 @@ import com.android.build.api.dsl.LibraryExtension import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.LibraryAndroidComponentsExtension +import com.android.build.gradle.internal.dsl.BaseAppModuleExtension import com.google.samples.apps.nowinandroid.configureJacoco import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.getByType -class AndroidLibraryJacocoConventionPlugin : Plugin { +class AndroidJacocoConventionPlugin: Plugin { override fun apply(target: Project) { with(target) { pluginManager.apply("jacoco") - val androidExtension = extensions.getByType() - androidExtension.buildTypes.configureEach { - enableAndroidTestCoverage = true - enableUnitTestCoverage = true + plugins.withId("com.android.application") { + val androidExtension = extensions.getByType() + androidExtension.buildTypes.configureEach { + enableAndroidTestCoverage = true + enableUnitTestCoverage = true + } + configureJacoco(extensions.getByType()) } - configureJacoco(extensions.getByType()) + plugins.withId("com.android.library") { + val androidExtension = extensions.getByType() + + androidExtension.buildTypes.configureEach { + enableAndroidTestCoverage = true + enableUnitTestCoverage = true + } + + configureJacoco(extensions.getByType()) + } } } } diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index 51ae627dc0..09a7237251 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) } diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 142637ff9c..24c4ced232 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) id("kotlinx-serialization") } diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index 4a6bcb66af..d6432cda30 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) alias(libs.plugins.nowinandroid.android.room) } diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index 34ea5ee78b..16454b42a0 100644 --- a/core/datastore/build.gradle.kts +++ b/core/datastore/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) } diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index cf3e4c51f8..48cc195d7d 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.roborazzi) } diff --git a/core/domain/build.gradle.kts b/core/domain/build.gradle.kts index 1918774597..64791562a8 100644 --- a/core/domain/build.gradle.kts +++ b/core/domain/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) id("com.google.devtools.ksp") } diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index 689a99e73d..f08123c869 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) id("kotlinx-serialization") id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 5d8a65d449..8c513f1547 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) } android { diff --git a/feature/bookmarks/build.gradle.kts b/feature/bookmarks/build.gradle.kts index 4e97176a2c..3b2d4ae0a0 100644 --- a/feature/bookmarks/build.gradle.kts +++ b/feature/bookmarks/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.feature) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) } android { diff --git a/feature/foryou/build.gradle.kts b/feature/foryou/build.gradle.kts index fd41d9a13a..cd1dc7556e 100644 --- a/feature/foryou/build.gradle.kts +++ b/feature/foryou/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.feature) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.roborazzi) } diff --git a/feature/interests/build.gradle.kts b/feature/interests/build.gradle.kts index ee6aaf122d..6d48d24ab4 100644 --- a/feature/interests/build.gradle.kts +++ b/feature/interests/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.feature) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) } android { namespace = "com.google.samples.apps.nowinandroid.feature.interests" diff --git a/feature/search/build.gradle.kts b/feature/search/build.gradle.kts index 98052e9ab5..0106da95cf 100644 --- a/feature/search/build.gradle.kts +++ b/feature/search/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.feature) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) } android { diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts index 4b9a72bdd0..01bbd63953 100644 --- a/feature/settings/build.gradle.kts +++ b/feature/settings/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.feature) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) } android { diff --git a/feature/topic/build.gradle.kts b/feature/topic/build.gradle.kts index d457b2f732..89bd69da94 100644 --- a/feature/topic/build.gradle.kts +++ b/feature/topic/build.gradle.kts @@ -17,7 +17,7 @@ plugins { alias(libs.plugins.nowinandroid.android.feature) alias(libs.plugins.nowinandroid.android.library.compose) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) } android { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6bc85e10e7..8b1467637a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -175,12 +175,11 @@ nowinandroid-android-application = { id = "nowinandroid.android.application", ve nowinandroid-android-application-compose = { id = "nowinandroid.android.application.compose", version = "unspecified" } nowinandroid-android-application-firebase = { id = "nowinandroid.android.application.firebase", version = "unspecified" } nowinandroid-android-application-flavors = { id = "nowinandroid.android.application.flavors", version = "unspecified" } -nowinandroid-android-application-jacoco = { id = "nowinandroid.android.application.jacoco", version = "unspecified" } nowinandroid-android-feature = { id = "nowinandroid.android.feature", version = "unspecified" } nowinandroid-android-hilt = { id = "nowinandroid.android.hilt", version = "unspecified" } nowinandroid-android-library = { id = "nowinandroid.android.library", version = "unspecified" } nowinandroid-android-library-compose = { id = "nowinandroid.android.library.compose", version = "unspecified" } -nowinandroid-android-library-jacoco = { id = "nowinandroid.android.library.jacoco", version = "unspecified" } +nowinandroid-android-jacoco = { id = "nowinandroid.android.jacoco", version = "unspecified" } nowinandroid-android-lint = { id = "nowinandroid.android.lint", version = "unspecified" } nowinandroid-android-room = { id = "nowinandroid.android.room", version = "unspecified" } nowinandroid-android-test = { id = "nowinandroid.android.test", version = "unspecified" } diff --git a/sync/work/build.gradle.kts b/sync/work/build.gradle.kts index 97e3eace2d..09c3e555f7 100644 --- a/sync/work/build.gradle.kts +++ b/sync/work/build.gradle.kts @@ -15,7 +15,7 @@ */ plugins { alias(libs.plugins.nowinandroid.android.library) - alias(libs.plugins.nowinandroid.android.library.jacoco) + alias(libs.plugins.nowinandroid.android.jacoco) alias(libs.plugins.nowinandroid.android.hilt) }