Skip to content

Commit 119a6ad

Browse files
committed
Set the Android attributes
1 parent 48b98c1 commit 119a6ad

4 files changed

Lines changed: 38 additions & 5 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ksp = "2.3.3"
77
# Version of KGP tapmoc is compatible with at runtime
88
kgp-compile-only = "1.9.0"
99
compile-sdk = "36"
10-
agp9 = "9.0.0-beta02"
10+
agp9 = "9.0.1"
1111
nmcp = "1.3.1-SNAPSHOT-bd3a2d8eeaa63dce9dfc2c9d8b63f4a2a98a50e7"
1212

1313
[libraries]

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pluginManagement {
77
content {
88
includeModule("com.gradleup.gratatouille", "gratatouille-processor")
99
includeModule("com.gradleup.nmcp", "nmcp-tasks")
10+
includeModule("com.gradleup.tapmoc", "tapmoc-tasks")
1011
}
1112
}
1213
}

tapmoc-gradle-plugin/src/main/kotlin/tapmoc/internal/TapmocExtensionImpl.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.gradle.api.NamedDomainObjectSet
44
import org.gradle.api.Project
55
import org.gradle.api.artifacts.Configuration
66
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
7+
import org.gradle.api.attributes.Attribute
78
import org.gradle.api.attributes.Category
89
import org.gradle.api.attributes.Usage
910
import org.gradle.api.provider.Property
@@ -94,6 +95,41 @@ internal abstract class TapmocExtensionImpl(private val project: Project) : Tapm
9495
it.isVisible = false
9596

9697
it.attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, usage))
98+
/**
99+
* For Android, select "release" by default. This is probably not 100% correct, but fixes errors like those:
100+
*
101+
* ```
102+
* Could not determine the dependencies of task ':openfeedback-m3:tapmocCheckClassFileVersions'.
103+
* > Could not resolve all dependencies for configuration ':openfeedback-m3:tapmocRuntimeDependencies'.
104+
* > Could not resolve project :openfeedback-resources.
105+
* Required by:
106+
* project :openfeedback-m3
107+
* > The consumer was configured to find a component for use during runtime. However we cannot choose between the following variants of project :openfeedback-resources:
108+
* - debugRuntimeElements
109+
* - releaseRuntimeElements
110+
* All of them match the consumer attributes:
111+
* - Variant 'debugRuntimeElements' capability 'io.openfeedback:openfeedback-resources:1.0.0-alpha.5-SNAPSHOT' declares a component for use during runtime:
112+
* - Unmatched attributes:
113+
* - Provides a library but the consumer didn't ask for it
114+
* - Provides attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.9.0' but the consumer didn't ask for it
115+
* - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' but the consumer didn't ask for it
116+
* - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
117+
* - Provides attribute 'org.gradle.jvm.environment' with value 'android' but the consumer didn't ask for it
118+
* - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
119+
* - Variant 'releaseRuntimeElements' capability 'io.openfeedback:openfeedback-resources:1.0.0-alpha.5-SNAPSHOT' declares a component for use during runtime:
120+
* - Unmatched attributes:
121+
* - Provides a library but the consumer didn't ask for it
122+
* - Provides attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.9.0' but the consumer didn't ask for it
123+
* - Provides attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' but the consumer didn't ask for it
124+
* - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it
125+
* - Provides attribute 'org.gradle.jvm.environment' with value 'android' but the consumer didn't ask for it
126+
* - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but the consumer didn't ask for it
127+
* ```
128+
*
129+
* I'm expecting the attributes to be ignored in the other cases because "missing attributes are a match" 🤞
130+
*/
131+
it.attributes.attribute(Attribute.of("com.android.build.gradle.internal.attributes.VariantAttr", String::class.java), "release")
132+
it.attributes.attribute(Attribute.of("artifactType", String::class.java), "jar")
97133
}
98134

99135
var firstTime = true

tests/agp9-kotlin/settings.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ pluginManagement {
77

88
includeBuild("../../")
99
includeBuild("../build-logic")
10-
11-
fun toto(settings: Settings) {
12-
settings.layout.rootDirectory.files()
13-
}

0 commit comments

Comments
 (0)