Two questions: Transitive Dependencies: gradle now...
# community-support
l
Two questions: Transitive Dependencies: gradle now produces a warning when using
configurations { api { transtive = false } }
Publishing non-transitive configuration 'apiElements'. This behavior has been deprecated. This will fail with an error in Gradle 10. Setting 'transitive = false' at the configuration level is ignored by publishing. Consider using 'transitive = false' on each dependency if this needs to be published.
Is there a good way to configure every dependency as transitive without literally adding
{ transitive = false }
to every dependency line? I have a task that generates files used during dev/compile. Added to
sourceSets.main.java.srcDir files('src/main/generated')
Which now throws a implicit dependency issue on a bunch of tasks. Is there any simpler way then adding 20
tasks.named(sourceSets.main.getCompileTaskName('java')).configure { t -> t.mustRunAfter(generate) }
lines? Note I don't want to make generate run every invocation of gradle. Hence mustRunAfter and not dependeOn. The generated files are checked into our vcs so they don't need to be generated every run. But also tested
sourceSets.main.java.srcDir generate.flatMap { it.output }
and didn't change anything.
v
Is there a good way to configure every dependency as transitive without literally adding
{ transitive = false }
to every dependency line?
Maybe you can do it in
withDependencies
of that configuration? No idea. But it might anyway be very questionable to do so even explicitly.
Which now throws a implicit dependency issue on a bunch of tasks.
If you ask me, committing generated files is horribly wrong. You should never check in files that are build artifacts. But if you must do so, just don't run the
generate
task together with the other tasks. Just call it on its own when you want to re-generate. The detection (at least currently) should not find the problem as long as you don't run the task in the same execution.
Besides that
dependsOn
would be a bad idea anyway. You would just do
sourceSets.main.java.srcDir(generate)
and thus every task that needs source automatically has the necessary dependency. The suggestions by that finding are pure symptom treatment you should usually avoid and fix the real problem instead.
l
Maybe you can do it in
withDependencies
of that configuration?
Naw anything I've tried results in
Mutating dependency after it has been finalized has been deprecated.
It seems that dependencies are finalized before they are realized for any of the functions in DependencySet
You should never check in files that are build artifacts.
waves hand Minecraft. When you see me ask fundamentally stupid things like this, know its because we are working on Minecraft related things.
sourceSets.main.java.srcDir(generate)
This doesn't work. Okay so as long as I don't execute the generate task, and any task that consumes the generated stuff in the same invocation. Then it should be fine. I'll just manually add these 'mustRunAfter' stuff to shut up the errors during my hacky
all
task im using to do bulk configuration/build cache testing. Would be nice if there was a simpler way to test this.
l
withDependencies
should be able to do this, I would think, if you instead copy the dependency and mutate the copy, clear the dependency set, and add the copies.
For the task ordering with generated sources question: you could also solve this by having a "dummy" task that you do establish dependsOn links for (which is much easier, just make sure the file collection is built by it) and have only that task mustRunAfter the generating task
Oh wait strike the first bit, this isn't a resolvable configuration to begin with is it so
withDependencies
shouldn't matter. In that case I think your best bet is to not publish
apiElements
but instead some other configuration, in which you have
addAllLater
the dependencies of
apiElements
, copied to make them non-transitive