This message was deleted.
# community-support
s
This message was deleted.
m
I've tried a bunch of things on the
implementation("...").attributesSchema { ... }
API but this API seems pretty obtuse for matching a specific value and nothing I throw at it seems to have any effect
I'm left with the ambiguity above and not sure how to get past it
I feel like I'm in the wrong API for specifying the consumer's intent
How would I say that I want
Attribute.of("net.devrieze.android", Boolean::class.javaObjectType)
to equal
false
?
v
implementation("...").attributesSchema { ... }
? It should be
dependencies.attributesSchema { ... ]
or probably
dependencies { attributesSchema { ... } }
. You need to register a custom attribute in the attribute schema and then you have to request it, either by setting the attribute on the configuration that is going to be resolved, or on the dependency directly.
m
How does one do
setting the attribute on the ... dependency directly
? That was what I was attempting to do with
implementation("...").attributesSchema { ... }
actually, I short-handed that wrong. More accurately, it was:
implementation("...") { attributesSchema { ... } }
v
-schema
attributesSchema is not defined in that scope, so you call it on the outher scope where it belongs and where you need to add your custom attibute to the attribute schema
And I strongly advice to use Kotlin DSL. You will get type-safe build scripts and amazingly better IDE support out-of-the-box. 🙂
m
I also tried
dependencies.attributeSchema { ... }
with the same result. I abandoned kotlin-dsl because it make the gradle/project kotlin version coupling issue far worse than without it (but that's a separate issue)
v
because it make the gradle/project kotlin version coupling issue far worse
Not sure what you mean. For build logic the Kotlin version is fixedly given by the Gradle version you use. But in any way the project Kotlin version is completely independent of that.
But anyway
Did you just do the
dependencies.attributeSchema
and ignored what I said multiple times already?
If yes, I'm not sure how much clearer I can say, that you need to add the custom attribute to the schema AND declare that you request it on the configuration or on the concrete dependency
Just adding the attribute to the schema is not enough, just requesting it is not enough, you have to do both
m
yeah, I can declare the attribute fine but I can't for the life of me figure out how to
declare that you request it on the configuration or on the concrete dependency
v
It would maybe also help if you would provide an MCVE of what you tried, then it is clear what you did and what you did not 🙂
I already told you, to subtract "schema", so for example
implementation("foo") { attributes { attribute(...) } }
, or similar on the configuration that is going to be resolved
m
hmm, that must be kotlin-dsl- provided. I don't see
attributes
on
DependencyHandlerScope
.
I was hoping for someone to point at an existing repo with an example of how to do this but looks like I need to spin up the MCVE instead
v
Why would you expect
attributes
on
DependencyHandlerScope
?
m
because
implementation("foo") { this }
is a
DependencyHandlerScope
and you suggested to use
implementation("foo") { attributes { ... } }
v
It is not, it is a
ModuleDependency
ExternalModuleDependency
to be precise
m
ah, I think the IDE is confused due to not being able to sync due to the root issue
v
Possible
And by it being Groovy DSL 😄
m
This is KotlinScript
v
Ah, ok, thought you don't use Kotlin DSL
Btw. did you actually have a look at the docs too? They also have examples. https://docs.gradle.org/current/userguide/variant_attributes.html#sec:declaring_attributes
m
yeah, nothing in the docs seemed to work.
v
Then I fear you really need to provide the MCVE. I at least do not have a repo to share, sorry.
m
kk. Based on what I'm seeing this might be a bug anyhow, at which point I'd need the MCVE regardless. I'll start there. Thanks for trying to get me through it though
v
You're welcome
m
FYI - turns out this was a bug relating to attribute specification in included builds: https://github.com/gradle/gradle/issues/23668
v
Oh, 😞 Thx for sharing
👍 1