Can I put the buildSrc folder of a convention plugin into some subdirectory?

I am getting more into Gradle ! :smiley: I have three projects which sit in the same folder and are related, but they are separate Gradle projects. I want to provide a convention plugin for these projects.

Say, the projects are proj-app, proj-schema and proj-helpers. proj-app has sub projects and there is another folder extra (with other stuff inside).

So the folder structure is like this:

    root-folder
    |
    +-- proj-app
    |   |
    |   +-- app-part-a
    |   |   |
    |   |   ...
    |   |   |
    |   |   +-- build.gradle
    |   |
    |   +-- app-part-b
    |   |   |
    |   |   ...
    |   |   |
    |   |   +-- build.gradle
    |   |
    |   +-- build.gradle
    |
    +-- proj-schema
    |   |
    |   ...
    |   |
    |   +-- build.gradle
    |
    +-- proj-helpers
    |   |
    |   ...
    |   |
    |   +-- build.gradle
    |
    +-- extra

Where does the convention plugin folder buildSrc have to go, so that I can use it in all 3 Gradle projects proj-app, proj-schema and `proj-helpers?

I would love to put the plugin folder buildSrc inside the (non-gradle) extra directory (for source control reasons). Is this possible?

Many thanks for any pointers!

No, buildSrc is for exactly one Gradle build and cannot be shared and its location is fixed defined unless you use symlinks (which you shouldn’t).

But, what you want is not buildSrc, but an included build. It is very similar to buildSrc, but imho almost always preferable and more flexible. You can name it however you like, put it wherever you like, and include it from all three of the other builds.

1 Like

Thanks for chiming in! Included Build is a Composite Build, right?

But don’t I need to make it a plugin, so that I can use it from all my three projects?

Included Build is a Composite Build, right?

Yes

But don’t I need to make it a plugin , so that I can use it from all my three projects?

It is a plugin you said.
Whether you have it in buildSrc or an included build does not really make a difference.

1 Like