Henning Habighorst
04/06/2025, 2:35 PM./gradlew buildSrc:spotlessApply spotlessApply
to run spotless apply to both buildSrc and all projects.
Given that buildSrc is isolated, there is probably no way to change this? (ChatGPT suggests a gradle task with exec but for many reasons that seems like an awful idea...)Henning Habighorst
04/06/2025, 2:42 PM./gradlew buildSrc:spotlessApply spotlessApply
⢠if spotless was configured in buildSrc/build.gradle.kts and in buildSrc as a convention kotlin scriptVampire
04/07/2025, 6:55 AMbuildSrc
is more or less a separate stand-alone build that "happens" to be built before your main build and added to your build scripts class paths through a parent class loader.
Yes, you cannot use things in buildSrc
to configure the buildSrc
build, that would be chicken-and-egg problem.
Just in case, as it sounds a bit like that, doing anything in buildSrc
will not apply anything to anything automatically. You just build custom build logic like convention plugins, that you then apply to those projects where you want those conventions to be used.
With buildSrc
you cannot depend on tasks from it from the main build, no.
Using exec is a horribly bad idea of course, as the I in AI does not mean "intelligence", not in nowadays tools.
If you would want to follow that approach, you would use the tooling API to drive the buildSrc
build.
But the better option would be to not use buildSrc
, but - what I prefer anyway - a normal included build. With that you can make a dependency from an including build's task to an included build's task.Henning Habighorst
04/07/2025, 7:40 AMThomas Broyer
04/07/2025, 8:23 AMincludeBuild("build-logic")
to your settings script.Henning Habighorst
04/07/2025, 8:30 AMVampire
04/07/2025, 7:04 PMbuildSrc
and an included build and most only manifest if you need special things or in certain situations.
But for most cases it is not really a noticable difference.
why is build src recommended then?
I don't recommend it. I would always recommend and prefer an included build unless forced to use
buildSrc
like when needing to monkey-patch 3rd party plugins.
That it is used in most places in the docs does not mean it is recommended. It simply is longer around than included builds and a tiny tad easier to start with.Vampire
04/07/2025, 7:05 PMbuildSrc
anyway. :-)