This message was deleted.
# dependency-management
s
This message was deleted.
v
isTransitive = false
on the configuration or the dependency just gets you the dependency but no transitives
c
in the configuration it throws an exception
v
Which?
c
I found
archives
would probably do what I need but is not using variant selection (I mean, no attributes, it's legacy)
v
Really,
isTransitive = false
is what you are after
Or
transitive = false
if you are old-school (using Groovy DSL 😄)
â›” 1
c
* What went wrong:
Could not determine the dependencies of task ':consumercompileJava'.
> Could not resolve all dependencies for configuration 'consumercompileClasspath'.
> Cannot change dependencies of dependency configuration 'producerapi' after it has been included in dependency resolution.
that's for the code:
Copy code
val jarOnly: Configuration by configurations.creating {
    isCanBeConsumed = false
    isCanBeResolved = true
    isTransitive=false
}

dependencies {
    jarOnly(project(":producer"))
    implementation(project(":producer"))
}
v
Do you have an MCVE? Doesn't sound like
isTransitive = false
should cause that
And no need for using String there if you have the configuration in a variable, then
jarOnly(...)
is available 🙂
c
I'll try to make a reproducer, next week in working hours. In the meantime the only "special" thing is that the code is in a convention plugins writen with kotlin-dsl
👌 1
ok, I got something else, the dependencies block actually includes 2 times the producer subproject
Copy code
dependencies {
    jarOnly(project(":produces:common")) {
        isTransitive = false
    }
    implementation(project(":produces:common"))
}
and the failure is complaining about the consumercompileJava
v
Shouldn't be a problem. Btw. do you still have the
isTransitive
on the configuration? Then having it on the dependency too ist just redundant. 😄
c
no,no, is just that I tried both
👌 1
v
It's really hard to guess what is going on. I just know I used
isTransitive
on both, dependencies and configurations successfully in the past, so I can just guess that it is something else going wrong in your setup, but I cannot imagine what.
Or well, if you resolve that
jarOnly
at configuration time and after it is resolved you try to add something to
api
in producer, then I think you would get that error.
c
and found the culprit even if I don't understand the issue:
Copy code
tasks.withType<Jar>().configureEach {
        from(jarOnly.map { zipTree(it) })
    }
but that should happens AFTER
I know it's related because commenting it out fixes the issue (obviously the jar is not as expected)
v
Add a breakpoint to both places, or some system out logging to verify the order. Maybe something is eagerly configuring any of the
Jar
tasks.
Maybe it works better if you use an artifact transform to do the exploding instead of using
zipTree
. That would also allow for the unzipped result to be reused if up to date.
c
good point, never used transforms before. going to sleep now, but thanks a lot for your help, at lest I know how to proceed with the investigation
👌 1