Shalom Ben-Zvi Kazaz
06/05/2024, 8:06 AMVampire
06/05/2024, 8:47 AMbuildSrc was built before the settings script evaluation and things from buildSrc were available in the settings script.
But since quite some time this is not the case anymore and buildSrc stuff cannot be used in the settings script.
You indeed need an included build that is included within pluginManagement { ... } to build a settings plugin that can be used.
buildSrc is always just available for its "parent" build, so an included build cannot use things from buildSrc of the including build. At least not without imho dirty tricks like symlinking buildSrc into the included build, so that it builds the same buildSrc.
There are slight and subtle differences between buildSrc and an included build, but for great lengths, you can indeed just rename the folder and include it instead. It is mostly edge-cases that only work in one but not the other.
For example you can have settings plugins in an included build, but not in buildSrc. Things from buildSrc are automatically available in all build scripts and thus also invalidate all tasks in all projects if anything changes, things from included builds are only available where they are used. By having the buildSrc classes available everywhere you get accessors for plugins generated, with included builds this is not the case - unless you apply a settings plugin from the included build as then the classes are also available in all the build scripts automatically and so the accessors can again be generated, but again everything will be out-of-date if anything changes. With buildSrc you can monkey-patch classes from 3rd party plugins, which does not work with included builds.
Generally, I prefer using an included build wherever possible, unless I have a good reason to use buildSrc, like when monkey-patching is necessary.Shalom Ben-Zvi Kazaz
06/05/2024, 9:16 AM