Skip to content
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

Configurations will not be able to change roles in 9.0 #718

Closed
jvandort opened this issue Jan 5, 2023 · 2 comments · Fixed by #721
Closed

Configurations will not be able to change roles in 9.0 #718

jvandort opened this issue Jan 5, 2023 · 2 comments · Fixed by #721

Comments

@jvandort
Copy link
Contributor

jvandort commented Jan 5, 2023

In Gradle 9.0, configurations will no longer be able to change roles. However, the following code changes the isCanBeResolved flag of a copied configuration:

val copy = configuration.copyRecursive().setTransitive(false)
copy.isCanBeResolved = true

Further, starting in 8.0, these copied configuration will carry the same deprecation warnings that the source configurations had. This means in 8.0, this plugin will start printing deprecation warnings when attempting to add dependencies to and resolve arbitrary copied configurations.

Finally, there are tentative plans to remove configuration copying in 9.0.

Is the copying here strictly necessary? Are there alternative approaches which can be used to avoid copying configurations and changing their flags?

@ben-manes
Copy link
Owner

We copy the configurations so that we can rewrite the dependencies to use dynamic versions. We then resolve the original and our modified version, compare the versions selected, and report on this difference. Originally this was a detached configuration, but there were too many Gradle bugs (like repository handler's deduplication logic either adding multiple or dropping repositories), so copying was the safest option. It also meant that we could honor configuration that was not always exposed, like resolution strategies.

Those flag changes were done in a best-effort fashion, as we swallow the exception if not resolvable. They did not exist when the plugin was written (Gradle 1.x) and were quirky (broken) in their first release, so had to be added for functionality. I believe that could be removed by changing to the newer resolution approach in v4 onward, e.g. see the dependency-analyze plugin's logic.

This plugin is mostly being casually maintained by contributors who graciously offer their time. It is ten years old, for what was meant to be a stop-gap that the Gradle team would fill when they had time (and often they said as much, but deferred that work due to this plugin being available). If you would like to see major improvements then PRs are very welcome (or advocate for a native feature that replaces this plugin). Otherwise it is whenever someone in the community kindly offers their energy, so we can't specify a timeline on when this might be fixed.

@jvandort
Copy link
Contributor Author

Thank you for all the context here. Plans to deprecate/remove copy are still tentative, though if we were to remove that we will certainly include this use-case in any future considerations.

As for not being able to change configuration roles -- that will certainly no longer be allowed in 9.0. I've prepared a PR which resolves the roles issue while leaving the copying behavior intact: #721

ben-manes pushed a commit that referenced this issue Jan 18, 2023
Fixes: #718

Updates plugin to only resolve resolvable configurations. As a result, configurations like
implementation are not resolved individually, but transitively via any resolvable configurations
which extend it. To handle this change, Resolver.kt was updated throughout to use
allDependencies and allDependencyConstraints in order to ensure the resolved/unresolved dependency
comparisons with the latest versions include inherited dependencies from non-resolvable configurations
which were previously being resolved individually.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants