Closed Goooler closed 2 years ago
I'm afraid that you'd probably have to load both through the init script; or at least apply them in the same way due to how Gradle classloading works.
You could try applying the plugin using the buildscript classpath syntax too, that should probably work. You can't use the plugin block (the preferred way to load plugins) from an init script.
Failed with:
FAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/goooler/.gradle/init.d/dependencyUpdates.gradle' line: 22
* What went wrong:
Failed to apply plugin class 'nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin'.
> Should be applied to the root project only
Configuration here: https://github.com/Goooler/DemoApp/blob/b815e9342b425c04ef00949b92242f8abfef06d8/gradle/init.d/dependencyUpdates.gradle#L7-L22
Maybe we should avoid applying tasks for rootProject
instead of throwing exception?
That check is there because it doesn't make any sense to apply the plugin to anything other than the root project. In your init script you are trying to apply it to all projects, triggering the error. Removing the error like your PR does, is not the solution :)
Maybe we should avoid applying tasks for rootProject instead of throwing exception?
Yes the easiest fix is not to use allProjects
but rootProject
in your init script. The dependency versions plugin also doesn't need to be applied to all projects for the version catalog plugin to work. I'd also would not use +
as the version because it can break a project at any time, but that's up to you.
Make sense. If we should note this usage in readme?
There's not much special about an init script, so I don't really think it's needed, but I can add the (old) build script syntax to the readme for those wanting to use that for some reason.
Tanks again.
Apply
versions-plugin
in a Gradle init script, then applyversion-catalog-update-plugin
in project'sbuild.gradle.kts
, output: