-
Notifications
You must be signed in to change notification settings - Fork 200
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
Resolve dependency constraints. #351
Conversation
Looks promising to me. Can you add an example of use in the samples? # Publish the latest version of the plugin to mavenLocal()
$ ./gradlew install
# Try out the samples
$ ./gradlew -p examples/groovy dependencyUpdate
$ ./gradlew -p examples/kotlin dependencyUpdate |
Thanks - added examples |
configuration.dependencyConstraints.each { dependency -> | ||
latest.add(createQueryDependency(dependency, revision)) | ||
} | ||
} catch (MissingPropertyException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other cases we've guarded using metaClass.respondsTo("...")
. Which do you consider preferable?
@@ -149,6 +159,19 @@ class Resolver { | |||
} | |||
} | |||
|
|||
/** Returns a variant of the provided dependency used for querying the latest version. */ | |||
@TypeChecked(SKIP) | |||
private Dependency createQueryDependency(DependencyConstraint dependency, String revision) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its probably not simpler to combine this with the other createQueryDependency
, though the duplication could lead to mistakes of fixing one instead of both.
Thanks for the PR and test case. I think it makes sense to go in. What do you think @jmfayard? Would constraints someday be used to implement BOMs or are they totally separate? My only concern is if someone has a large BOM but only uses a few dependencies, and the constraint resolution causes them to see the universe. That seems unlikely but worth asking. |
I have no further remarks. I learned a lot of new things by reading the two links from the PR |
Switched to using It's an interesting question of if in the future, Gradle would internally implement a BOM dependency by translating it into constraints. I feel as if this wouldn't happen, since a |
That makes sense. Thanks again. 😄 |
Releasing v26. |
Dependency constraints can be used to set versions, and in particular can be used with the
java-platform
plugin to define all constraints in a single location. It would be convenient if these constraints were resolved by the plugin since then instead of resolving the dependencies of all projects in a monorepo controlled by a platform, just need to resolve a single project for better performance and simpler output.I am wondering whether this feature should be restricted to projects with the java-platform plugin. Let me know if you have thoughts.
Reference
Fixes #350