From 119a6ad7cdb82e1a5ccf06668e5d85bb3390a42a Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 30 Mar 2026 16:26:03 +0200 Subject: [PATCH 1/5] Set the Android attributes --- gradle/libs.versions.toml | 2 +- settings.gradle.kts | 1 + .../tapmoc/internal/TapmocExtensionImpl.kt | 36 +++++++++++++++++++ tests/agp9-kotlin/settings.gradle.kts | 4 --- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c2c2d9c..f9e5cfe 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ ksp = "2.3.3" # Version of KGP tapmoc is compatible with at runtime kgp-compile-only = "1.9.0" compile-sdk = "36" -agp9 = "9.0.0-beta02" +agp9 = "9.0.1" nmcp = "1.3.1-SNAPSHOT-bd3a2d8eeaa63dce9dfc2c9d8b63f4a2a98a50e7" [libraries] diff --git a/settings.gradle.kts b/settings.gradle.kts index 962609b..cddba85 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,6 +7,7 @@ pluginManagement { content { includeModule("com.gradleup.gratatouille", "gratatouille-processor") includeModule("com.gradleup.nmcp", "nmcp-tasks") + includeModule("com.gradleup.tapmoc", "tapmoc-tasks") } } } diff --git a/tapmoc-gradle-plugin/src/main/kotlin/tapmoc/internal/TapmocExtensionImpl.kt b/tapmoc-gradle-plugin/src/main/kotlin/tapmoc/internal/TapmocExtensionImpl.kt index a1e4d04..65cbace 100644 --- a/tapmoc-gradle-plugin/src/main/kotlin/tapmoc/internal/TapmocExtensionImpl.kt +++ b/tapmoc-gradle-plugin/src/main/kotlin/tapmoc/internal/TapmocExtensionImpl.kt @@ -4,6 +4,7 @@ import org.gradle.api.NamedDomainObjectSet import org.gradle.api.Project import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.component.ModuleComponentIdentifier +import org.gradle.api.attributes.Attribute import org.gradle.api.attributes.Category import org.gradle.api.attributes.Usage import org.gradle.api.provider.Property @@ -94,6 +95,41 @@ internal abstract class TapmocExtensionImpl(private val project: Project) : Tapm it.isVisible = false it.attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, usage)) + /** + * For Android, select "release" by default. This is probably not 100% correct, but fixes errors like those: + * + * ``` + * Could not determine the dependencies of task ':openfeedback-m3:tapmocCheckClassFileVersions'. + * > Could not resolve all dependencies for configuration ':openfeedback-m3:tapmocRuntimeDependencies'. + * > Could not resolve project :openfeedback-resources. + * Required by: + * project :openfeedback-m3 + * > The consumer was configured to find a component for use during runtime. However we cannot choose between the following variants of project :openfeedback-resources: + * - debugRuntimeElements + * - releaseRuntimeElements + * All of them match the consumer attributes: + * - Variant 'debugRuntimeElements' capability 'io.openfeedback:openfeedback-resources:1.0.0-alpha.5-SNAPSHOT' declares a component for use during runtime: + * - Unmatched attributes: + * - Provides a library but the consumer didn't ask for it + * - Provides attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.9.0' but the consumer didn't ask for it + * - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it + * - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it + * - Provides attribute 'org.gradle.jvm.environment' with value 'android' but the consumer didn't ask for it + * - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it + * - Variant 'releaseRuntimeElements' capability 'io.openfeedback:openfeedback-resources:1.0.0-alpha.5-SNAPSHOT' declares a component for use during runtime: + * - Unmatched attributes: + * - Provides a library but the consumer didn't ask for it + * - Provides attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.9.0' but the consumer didn't ask for it + * - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it + * - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it + * - Provides attribute 'org.gradle.jvm.environment' with value 'android' but the consumer didn't ask for it + * - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it + * ``` + * + * I'm expecting the attributes to be ignored in the other cases because "missing attributes are a match" 🤞 + */ + it.attributes.attribute(Attribute.of("com.android.build.gradle.internal.attributes.VariantAttr", String::class.java), "release") + it.attributes.attribute(Attribute.of("artifactType", String::class.java), "jar") } var firstTime = true diff --git a/tests/agp9-kotlin/settings.gradle.kts b/tests/agp9-kotlin/settings.gradle.kts index 51cc0c3..92be65e 100644 --- a/tests/agp9-kotlin/settings.gradle.kts +++ b/tests/agp9-kotlin/settings.gradle.kts @@ -7,7 +7,3 @@ pluginManagement { includeBuild("../../") includeBuild("../build-logic") - -fun toto(settings: Settings) { - settings.layout.rootDirectory.files() -} From d023ffc130f10cdc360717e03c2079ad8c273652 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 30 Mar 2026 00:40:00 +0200 Subject: [PATCH 2/5] Fix integration tests --- .../src/kgp/kotlin/tapmoc/internal/KgpImpl.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tapmoc-gradle-plugin/src/kgp/kotlin/tapmoc/internal/KgpImpl.kt b/tapmoc-gradle-plugin/src/kgp/kotlin/tapmoc/internal/KgpImpl.kt index bcd702c..7360727 100644 --- a/tapmoc-gradle-plugin/src/kgp/kotlin/tapmoc/internal/KgpImpl.kt +++ b/tapmoc-gradle-plugin/src/kgp/kotlin/tapmoc/internal/KgpImpl.kt @@ -140,6 +140,12 @@ private class KgpImpl(private val dependencyHandler: DependencyHandler, extensio } } } + /** + * We also need to fight AGP there: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/internal/utils/kgpUtils.kt;l=386;drc=24548ccac3813558373462f04d14e6738141624d + * + * This is assuming there will always be an "api" configuration... + */ + dependencyHandler.add("api", "org.jetbrains.kotlin:kotlin-stdlib:${version}") } } } From 0a62f59406ae0ad5d084b49f6fecd410ab087f0d Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 30 Mar 2026 22:55:05 +0200 Subject: [PATCH 3/5] Use Gradle 9.4.0 everywhere --- tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties index 317a409..d9e7cee 100644 --- a/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -# See https://github.com/gradle/gradle/pull/34540 -distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-9.4.0-20251215022449+0000-bin.zip +distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 6d06bef4a3a74fbc9b5be520e682d138d1f7e7c0 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 30 Mar 2026 23:02:58 +0200 Subject: [PATCH 4/5] Really fix the url --- tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties index d9e7cee..dbc3ce4 100644 --- a/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-9.4.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From 547fcb9968348529ef4c1d2056a5b9455cd6850d Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 30 Mar 2026 23:14:53 +0200 Subject: [PATCH 5/5] Fix build --- tests/gradle-plugin/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/gradle-plugin/build.gradle.kts b/tests/gradle-plugin/build.gradle.kts index e174dbd..6627d5a 100644 --- a/tests/gradle-plugin/build.gradle.kts +++ b/tests/gradle-plugin/build.gradle.kts @@ -2,7 +2,8 @@ import tapmoc.Severity plugins { id("com.gradleup.tapmoc") - `embedded-kotlin` + // Use a version of KGP that can target 1.8 + id("org.jetbrains.kotlin.jvm").version("2.2.10") id("java-gradle-plugin") // needs to be before check.publication id("check.publication") }