This message was deleted.
# dependency-management
s
This message was deleted.
t
If you want the
bucketClasspath
from
consumer
to get the
bucketClasspath
from
producer
you need to declare attributes on the configurations so that Gradle picks the appropriate variant, otherwise it will take the default one, which likely will be
runtimeElements
. https://docs.gradle.org/current/userguide/variant_model.html
j
Looks a lot like you use the Kotlin plugin, right? That adds the "stdlib" by default. I am not sure where, but I won't be surprised if it adds it everywhere. I think there is an option to turn off that behavior in the Kotlin plugin.
t
ohhhh! it is probably KGP adding the stdlib to all configurations by default. My god how awful! (although... it also added the producer.jar...) @Thomas Broyer yes I am aware I need attributes. The question was why, without any attributes, I was getting dependencies anyway. I will experiment later with a Java project to see if I get this same weird behavior.
c
Kgp adds stdlib to compile classpath, but you are getting all transitive dependencies from
:producer:runtimeElements
I believe everything works as expected
If you don't want to add attributes, do:
Copy code
dependencies {
  bucket(project(path = ":producer", configuration = "bucket"))
}
t
no, I do want to add attributes. I'm simply trying to understand why, absent any, I got dependencies. Why would I get runtimeElements?
my
bucket
configuration has no relationship to existing configurations
c
consumerbucket has a dependency on producerrubtimeElements (aka default)
t
why?
where is that specified? is it documented?
c
When you add any dependency, the resolution will find the best match given attributes, by default it will be
default
t
I see! thanks for clearing up the mystery. (a mystery to me anyway)
c
I'm looking at the docs (from my phone)
But please, try using the name of the configuration for the dependency and validate I'm saying the truth
t
can you send me that doc link?
I tried debugging by looking at
outgoingVariants
and
resolvableConfigurations
but I didn't see this. I could have just missed it; there's a lot of output to those tasks
c
I would like to send you the link...but I haven't found it really (and to be true I'm not really focused on it)
👍 1
t
I think the link is the one I posted earlier. (either that, or https://docs.gradle.org/current/userguide/cross_project_publications.html or https://docs.gradle.org/current/userguide/variant_attributes.html#sec:abm_algorithm, and also see upper in the page about the default values of some attributes, and compatibility and disambiguation rules)
Let's get the question reversed: why would consumerbucketElements have a dependency on consumerbucketElements specifically, rather than consumerruntimeElements? Variant name? They don't participate in the variant selection (https://docs.gradle.org/current/userguide/variant_model.html#sec:variant-aware-matching)
Gradle should tell you which variant it selected and why, with `dependencyInsight`:
Copy code
./gradlew :consumer:dependencyInsight --configuration bucketElements --dependency :producer
t
this was the declaration
Copy code
// consumer/build.gradle
dependencies {
  bucket project(':producer')
}
there's no obvious reason to me, looking at that, why it would ever get
runtimeElements
from
:producer
. The consumable configuration associated with the
bucket
configuration doesn't have any artifacts associated with it. In fact, I'm not actually sure how gradle gets from the dependency scope (
bucket
) to the consumable configuration (
bucketElements.extendsFrom(bucket)
)