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/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}") } } } 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() -} 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") } diff --git a/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/tests/gradle-plugin/gradle/wrapper/gradle-wrapper.properties index 317a409..dbc3ce4 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/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME