Skip to content

dependencyUpdates for example projects#1893

Merged
Jolanrensen merged 4 commits into
masterfrom
dependencyUpdates
Jun 15, 2026
Merged

dependencyUpdates for example projects#1893
Jolanrensen merged 4 commits into
masterfrom
dependencyUpdates

Conversation

@Jolanrensen

Copy link
Copy Markdown
Collaborator

Helps #1661

Adapts dfbuild.dependencyUpdates convention plugin:

  • Makes versionsToSync type safe
    • (Note, we always need to format versions with -, but we already do this)
  • Added every missing dependency from our examples in the main gradle/libs.versions.toml
  • Created exampleDependencyUpdates configuration that consumes every dependency from our examples, so the dependencyUpdate task is aware of them.
    • (I would have liked this to be automatic, but I cannot find a way to do that in a transparent manner, unfortunately...)
    • (If you know a better way, or if I missed a dependency, please let me know!)

As you can see, running dependencyUpdates now also detects out-of-date android dependencies :D
image

@Jolanrensen Jolanrensen added this to the Post-RC milestone Jun 11, 2026
@Jolanrensen Jolanrensen added examples Something related to the examples infrastructure GitHub actions, Gradle Scripts, Writerside, etc. labels Jun 11, 2026
@Jolanrensen Jolanrensen force-pushed the dependencyUpdates branch 2 times, most recently from 273f06e to fbc69c9 Compare June 11, 2026 09:48
@Jolanrensen Jolanrensen marked this pull request as ready for review June 11, 2026 09:49

// 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 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Jolanrensen Jolanrensen Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
image
which creates a provider based around this Callable<String> (DefaultProvider<String>.value):
image
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but can't it be broken by any Gradle internal implementation change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but only when we bump gradle versions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, left the note about it somewhere
(smth like if something was broken after gradle version bump, then check this method 😄 )

@Jolanrensen Jolanrensen Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Jolanrensen Jolanrensen merged commit 7271809 into master Jun 15, 2026
4 checks passed
@Jolanrensen Jolanrensen deleted the dependencyUpdates branch June 15, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Something related to the examples infrastructure GitHub actions, Gradle Scripts, Writerside, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants