dependencyUpdates for example projects#1893
Conversation
273f06e to
fbc69c9
Compare
|
|
||
| // tiny reflection-based solution to retrieve the original version name from the accessor, | ||
| // so we can keep the list of version type-safe | ||
| fun Any.getVersionName(): String { |
There was a problem hiding this comment.
Looks unsafe. Is there any not reflection-based solution?
And do I understand correctly that we only need this for referencing versions through
libs.versions extensions?
There was a problem hiding this comment.
Safety is relative ;P it's a trade-off. We need reflection to access the version name, the version itself can be accessed normally.
Either we have a String-based solution, which fails silently when a typo is made and will result in out-of-date versions in examples, or we use type-safe accessors which don't compile on typos and break only when Gradle changes how they are generated.
Btw, the reason reflection is needed, is because the accessor returns a simple Provider<String>, which, when executed, returns the version itself without any reference to the name of the version (which is what we need to sync them).
For instance libs.versions.spark4 corresponds to

which creates a provider based around this Callable<String> (DefaultProvider<String>.value):

where we can fetch that exact String from the first screenshot.
(For accessors which are also groups, like maven, because there's also maven.surefire, I need to first call .asProvider() on them, hence the second part of the function)
I do hope Gradle eventually adds a better way to reference version names safely.
I will add some guards around it, so we get more helpful exceptions when Gradle does change.
There was a problem hiding this comment.
I see, but can't it be broken by any Gradle internal implementation change?
There was a problem hiding this comment.
yes, but only when we bump gradle versions
There was a problem hiding this comment.
Ok, left the note about it somewhere
(smth like if something was broken after gradle version bump, then check this method 😄 )
There was a problem hiding this comment.
haha I already added a helpful exception in that function that when it breaks that function should be fixed ;P
Btw it won't break in Gradle 9.6.0 ;P Already tested it with the RC version.
…s so we can track dependencyUpdates
…build.buildExampleProjects
db12afa to
42b2c45
Compare
Helps #1661
Adapts
dfbuild.dependencyUpdatesconvention plugin:versionsToSynctype safe-, but we already do this)exampleDependencyUpdatesconfiguration that consumes every dependency from our examples, so thedependencyUpdatetask is aware of them.As you can see, running

dependencyUpdatesnow also detects out-of-date android dependencies :D