How gradle build can detect buildSrc in the parent root folder

project layout:

so if I build under the library-a path, like this:

\sample_convention_plugins-groovy-dsl\library-a>gradle build --info

gradle is not supposed to know the buildSrc in the parent folder, because it’s not in its build context(library-a), at least Maven can not do this.

But actually, gradle can detect the convention plugin in the buildSrc and successfully build under that subpath , and I found some relative logs in the output:

Starting Build
Settings evaluated using settings file 'E:\chromeDL\sample_convention_plugins-groovy-dsl\settings.gradle'.
Projects loaded. Root project using build file 'E:\chromeDL\sample_convention_plugins-groovy-dsl\build.gradle'.
Included projects: [root project 'sample', project ':internal-module', project ':library-a', project ':library-b']

So what mechanism this is, can I find some explanation in doc?

Even if you start your build within library-a, it is not built stand-alone.
It is still a subproject within the whole build defined by the settings.gradle(.kts).
And that build has the buildSrc automatically run first and prefixed to all build script class paths.
You can also see that in the output you pasted.
All four projects are recognized and known.

Btw. you should practically never use gradle to run any Gradle build, but always the Gradle wrapper (gradlew) that is checked in together with the project. It defines the version of Gradle to run the build with, with which it was tested, designed for, and known to work properly with. You never need a version of Gradle installed locally to run a Gradle build, unless it misses the four Gradle wrapper files, which in my opinion is a build bug. :slight_smile: