From bffa2b0a2b860fb26d13dc690c4c4b59c797ca81 Mon Sep 17 00:00:00 2001 From: Guillermo Mazzola Date: Fri, 20 Oct 2023 11:39:38 +0200 Subject: [PATCH] Fixed `finalizeDSL` block preventing property changes --- demo-project/app/build.gradle.kts | 8 +++++--- demo-project/domain/build.gradle.kts | 2 ++ demo-project/login/build.gradle.kts | 6 ++++-- demo-project/ui-tests/build.gradle.kts | 8 +++++++- gradle/libs.versions.toml | 3 ++- .../test/aggregation/AndroidTestBaseAggregationPlugin.kt | 7 +++---- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/demo-project/app/build.gradle.kts b/demo-project/app/build.gradle.kts index 6f00d1c..1ee808e 100644 --- a/demo-project/app/build.gradle.kts +++ b/demo-project/app/build.gradle.kts @@ -3,14 +3,16 @@ plugins { alias(libs.plugins.kotlin.android) } +java.toolchain.languageVersion.set(JavaLanguageVersion.of(11)) + android { namespace = "com.example.myapplication" - compileSdk = libs.versions.android.sdk.get().toInt() buildFeatures.viewBinding = true + compileSdk = libs.versions.android.compileSDK.get().toInt() defaultConfig { - applicationId = "com.example.myapplication" - minSdk = 21 + minSdk = libs.versions.android.minSDK.get().toInt() + versionCode = 1 versionName = "1.0" diff --git a/demo-project/domain/build.gradle.kts b/demo-project/domain/build.gradle.kts index c620180..cfb226e 100644 --- a/demo-project/domain/build.gradle.kts +++ b/demo-project/domain/build.gradle.kts @@ -3,6 +3,8 @@ plugins { jacoco } +java.toolchain.languageVersion.set(JavaLanguageVersion.of(11)) + dependencies { testImplementation(libs.junit) } diff --git a/demo-project/login/build.gradle.kts b/demo-project/login/build.gradle.kts index 0868828..8d5b1cd 100644 --- a/demo-project/login/build.gradle.kts +++ b/demo-project/login/build.gradle.kts @@ -3,14 +3,16 @@ plugins { alias(libs.plugins.kotlin.android) } +java.toolchain.languageVersion.set(JavaLanguageVersion.of(11)) + android { namespace = "com.example.login" - compileSdk = libs.versions.android.sdk.get().toInt() buildFeatures.viewBinding = true testFixtures.enable = true + compileSdk = libs.versions.android.compileSDK.get().toInt() defaultConfig { - minSdk = 21 + minSdk = libs.versions.android.minSDK.get().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/demo-project/ui-tests/build.gradle.kts b/demo-project/ui-tests/build.gradle.kts index 3c3012b..bb1c3ca 100644 --- a/demo-project/ui-tests/build.gradle.kts +++ b/demo-project/ui-tests/build.gradle.kts @@ -3,9 +3,15 @@ plugins { alias(libs.plugins.kotlin.android) } +java.toolchain.languageVersion.set(JavaLanguageVersion.of(11)) + android { namespace = "com.example.app.test" - compileSdk = libs.versions.android.sdk.get().toInt() + + compileSdk = libs.versions.android.compileSDK.get().toInt() + defaultConfig { + minSdk = libs.versions.android.minSDK.get().toInt() + } targetProjectPath = projects.demoProject.app.dependencyProject.path diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 72b97f1..fce0bfc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,8 @@ [versions] kotlin = "1.9.10" agp = "8.1.2" -android-sdk = "34" +android-minSDK = "21" +android-compileSDK = "34" androidx-lifecycle = "2.6.2" androidx-navigation = "2.7.4" diff --git a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt index 81d62a7..2662a0f 100644 --- a/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt +++ b/plugin/src/main/kotlin/io/github/gmazzo/android/test/aggregation/AndroidTestBaseAggregationPlugin.kt @@ -2,9 +2,9 @@ package io.github.gmazzo.android.test.aggregation +import org.gradle.api.DomainObjectSet import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.kotlin.dsl.aggregateTestCoverage import org.gradle.kotlin.dsl.apply @@ -13,7 +13,7 @@ import org.gradle.kotlin.dsl.typeOf internal abstract class AndroidTestBaseAggregationPlugin : Plugin { - internal abstract val extendedProperties: ListProperty> + abstract val extendedProperties: DomainObjectSet> override fun apply(target: Project): Unit = with(target) { apply(plugin = "com.android.base") @@ -34,8 +34,7 @@ internal abstract class AndroidTestBaseAggregationPlugin : Plugin { } androidComponents.finalizeDsl { - extendedProperties.finalizeValue() - extendedProperties.get().forEach { it.finalizeValue() } + extendedProperties.all { finalizeValue() } } }