buildSrc not picked up from explicit root project

My source repository has a flat layout for “top-level” projects within a particular branch ‘location(topProjectName) = $repoRoot/$topProjectName/$branchName/src’ that does not allow the root project to be discovered automatically. The root project has to be another top-level project such as ‘$repoRoot/master/$branchName/src’, and I want to avoid any branch-specific settings in the source tree.

I have tried putting a settings.gradle in each top-level project as follows:




settings.gradle - “rootProject.projectDir = settingsDir.parentFile”

build.gradle - “apply plugin: MyPlugin”

It turns out that buildSrc is not built abd my plugin is not available in MyTop. Although this is a hacky way of finding the shared buildSrc, I think it should work.

Otherwise, how can I get gradle to find the root project in ‘master/$branchName/src’ when running gradle in ‘$topProjectName/$branchName/src’ without having to hardcode the branch name or script outside gradle?

I don’t understand your project layout. ‘buildSrc’ must be located in the build’s root project directory.

I think the confusion is around the distiction between settingsDir and rootDir. My settings.gradle is not in the root directory; it specifies the location of the root directory. I suspect this confusion is also the cause for the bug.