-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
withDependencies allows project dependencies to be added to the DependencySet after the task graph is ready #21490
Comments
Sorry that you're having trouble with Gradle! Your issue lacks information about how to reproduce the problem you're having. A reproducer project can really help us track down and fix your problem quicker. We may also be able to suggest workarounds or ways to avoid the problem if we can reproduce it. You can use the following as a base for your reproducer: https://github.com/gradle/gradle-issue-reproducer |
Reproducer is here https://github.com/DanielThomas/gradle-issue-21490. The workaround is to configure regular project dependencies so they exist when the task graph is created. |
I hit this today. I think the problem is not the project dependency, but the fact that the resolution is skipped in certain cases and that the "withDependeny" actions are not triggered then: This is a "micro-optimization" in Gradle for Java compilation which skips the resolution of dependencies during task graph calculation. And instead checks the direct dependencies directly for projects to compile. I did a bit of debug, and I think the problem is that Workarounds:
FixI think this inconsistent behavior is concerning and this should be fixed. |
Another reproducer: (Make sure to checkout the indicated commit ID - withDependencies is used in the |
This is still an issue in Gradle |
One of our teams building a plugin got taken surprise when they didn't realise they'd race the task graph by using
withDependencies
to add project dependencies.Expected Behavior
Project dependencies should not be able to be added to configurations after configuration time.
Current Behavior
The configuration resolves successfully but without the dependency does not have the artifacts from the dependent project. When using incremental builds, you could accidentally be using an artifact from a previous build.
Context
This feels rare and we were able to identify the problem for them pretty easily, but feels like a gotcha Gradle should avoid. May be your existing plans for configurations avoids this, but wanted to document it as a potential gotcha.
Steps to Reproduce
implementation
project dependency added inwithDependencies
dependencies
task:a:compileJava
and note that:b
isn't considered a dependencyYour Environment
Gradle 7.5.1
The text was updated successfully, but these errors were encountered: