# Custom plugin in a multi java project setup

**URL:** <https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [May 15, 2018, 6:24am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935 "2018-05-15T06:24:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![gadieichhorn](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gadieichhorn/32/6119_2.png) [@gadieichhorn](https://discuss.gradle.org/u/gadieichhorn)\
**Post date:** [May 15, 2018, 6:24am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/1 "2018-05-15T06:24:52Z")

</div>

Hi,

**Using Gradle 4.7.**

I have some build code that can benefit from being a plugin. I created a plugin project and try to use it with the other subprojects.

Can anyone share an example project were this setup works?  
Seemed that all old examples don’t work.

Thanks,  
Gadi.

---

<div class="post-metadata">

**Author:** ![staffanf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/staffanf/32/6017_2.png) [@staffanf](https://discuss.gradle.org/u/staffanf)\
**Post date:** [May 17, 2018, 7:02am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/2 "2018-05-17T07:02:07Z")

</div>

Place it in buildSrc, then it will be available to the rest of the build.  
[https://guides.gradle.org/writing-gradle-plugins/](https://guides.gradle.org/writing-gradle-plugins/) along with [https://docs.gradle.org/4.7/userguide/java\_gradle\_plugin.html](https://docs.gradle.org/4.7/userguide/java_gradle_plugin.html) covers the basic of getting started.

In the [gradle-all.zip](https://gradle.org/next-steps/?version=4.7&format=all) you can find `samples/multiProjectBuildSrc` which has a simple working example too.

---

<div class="post-metadata">

**Author:** ![gadieichhorn](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gadieichhorn/32/6119_2.png) [@gadieichhorn](https://discuss.gradle.org/u/gadieichhorn)\
**Post date:** [May 17, 2018, 7:56am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/3 "2018-05-17T07:56:23Z")

</div>

thanks @staffanf

I cannot make this to work:  
When I apply the plugin it tell me it is not found.  
'plugin with id xxx not found

I tried with full name or just plugin name.  
I have a properties file with the plugin class

1. my plugin is java (not groovey)
2. my projects organised in multi level nested folder structure

any java plugin example?  
Thanks

---

<div class="post-metadata">

**Author:** ![staffanf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/staffanf/32/6017_2.png) [@staffanf](https://discuss.gradle.org/u/staffanf)\
**Post date:** [May 17, 2018, 8:47am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/4 "2018-05-17T08:47:06Z")

</div>

Create a minimal viable example of what does not work and post it here or on github.  
Then we can help you get it started.

---

<div class="post-metadata">

**Author:** ![gadieichhorn](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gadieichhorn/32/6119_2.png) [@gadieichhorn](https://discuss.gradle.org/u/gadieichhorn)\
**Post date:** [May 17, 2018, 10:34am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/5 "2018-05-17T10:34:23Z")

</div>

Thanks @staffanf

Here is my example code -\> [https://github.com/gadieichhorn/gradle-java-multimodule](https://github.com/gadieichhorn/gradle-java-multimodule)

Thanks in advance.  
Gadi.

---

<div class="post-metadata">

**Author:** ![staffanf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/staffanf/32/6017_2.png) [@staffanf](https://discuss.gradle.org/u/staffanf)\
**Post date:** [May 17, 2018, 11:30am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/6 "2018-05-17T11:30:40Z")

</div>

Here’s a patch for a fixed version:  
[https://pastebin.com/guTtmEU4](https://pastebin.com/guTtmEU4)

The main problem was that I don’t think you can have subprojects in `buildSrc`

---

<div class="post-metadata">

**Author:** ![gadieichhorn](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gadieichhorn/32/6119_2.png) [@gadieichhorn](https://discuss.gradle.org/u/gadieichhorn)\
**Post date:** [May 17, 2018, 12:04pm UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/7 "2018-05-17T12:04:13Z")

</div>

thanks @staffanf, can you submit a pull request?

Can you seperate plugins with different properties files in the same buildSrc directory?

Thanks.

---

<div class="post-metadata">

**Author:** ![staffanf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/staffanf/32/6017_2.png) [@staffanf](https://discuss.gradle.org/u/staffanf)\
**Post date:** [May 17, 2018, 2:20pm UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/8 "2018-05-17T14:20:17Z")

</div>

Yes, just use more blocks in the dsl like:

```gradle
 gradlePlugin {
    plugins {
        integrationPlugin {
            id = 'com.rds.example.gradle.integration-plugin'
            implementationClass = 'com.rds.example.gradle.IntegrationPlugin'
        }
        pluginB {
            id = 'another.id'
            implementationClass = 'some.other.PluginClass'
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [May 17, 2018, 2:20pm UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/9 "2018-05-17T14:20:32Z")

</div>

There’s also nothing wrong with `buildSrc` being a multi-project build. However, the root project must have a `runtime` dependency on the subprojects you want to include (see [Organizing Build Logic - Build Sources](https://docs.gradle.org/current/userguide/organizing_build_logic.html#sec:build_sources)).

There’s no problem including all subprojects in one go, if that’s what you want:

_buildSrc/build.gradle_

```groovy
dependencies {
    runtime subprojects
}

```

[https://docs.gradle.org/current/userguide/organizing\_build\_logic.html#sec:build\_sources](https://docs.gradle.org/current/userguide/organizing_build_logic.html#sec:build_sources)

---

<div class="post-metadata">

**Author:** ![gadieichhorn](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gadieichhorn/32/6119_2.png) [@gadieichhorn](https://discuss.gradle.org/u/gadieichhorn)\
**Post date:** [May 25, 2018, 6:31am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/10 "2018-05-25T06:31:15Z")

</div>

awesome! thanks @jjustinic

---

<div class="post-metadata">

**Author:** ![gadieichhorn](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/gadieichhorn/32/6119_2.png) [@gadieichhorn](https://discuss.gradle.org/u/gadieichhorn)\
**Post date:** [May 25, 2018, 6:32am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/11 "2018-05-25T06:32:08Z")

</div>

thanks @staffanf, cool, this is what I thought.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [June 24, 2025, 11:35am UTC](https://discuss.gradle.org/t/custom-plugin-in-a-multi-java-project-setup/26935/12 "2025-06-24T11:35:06Z")

</div>

Split this topic on June 24, 2025, 11:35am UTC

A post was split to a new topic: [Applying buildSrc plugin to settings](https://discuss.gradle.org/t/applying-buildsrc-plugin-to-settings/51227)
