# BuildScript, Plugin and multiple files

**URL:** <https://discuss.gradle.org/t/buildscript-plugin-and-multiple-files/33127>\
**Category:** Help/Discuss\
**Created:** [September 11, 2019, 8:46am UTC](https://discuss.gradle.org/t/buildscript-plugin-and-multiple-files/33127 "2019-09-11T08:46:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MickD](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mickd/32/5382_2.png) [@MickD](https://discuss.gradle.org/u/MickD)\
**Post date:** [September 11, 2019, 8:46am UTC](https://discuss.gradle.org/t/buildscript-plugin-and-multiple-files/33127/1 "2019-09-11T08:46:11Z")

</div>

Hello,

I’m working on multiple project and i want to have common files to setup build.

I’d like to have only the build.gradle specific to the project and have files to include and configure plugins.

When I put everything in my build.gradle, everything is ok. When I separate in files (and include files in build.gradle) it fails to find plugin

Exemple :

> ==== build.gradle====
> 
> buildscript {  
> repositories {  
> ivy {  
> name = “repo-spotless”   
> }  
> }  
> dependencies {  
> classpath “com.diffplug.spotless:spotless-plugin-gradle:3.0.0”  
> }  
> }  
> apply plugin: ‘com.diffplug.gradle.spotless’

=\> if i put this into a “spotless.gradle” which is included by build.gradle it fails.

> ====build.gradle====  
> apply from: ‘spotless.gradle’

> ====spotless.gradle====  
> buildscript {  
> repositories {  
> ivy {  
> name = “repo-spotless”   
> }  
> }  
> dependencies {  
> classpath “com.diffplug.spotless:spotless-plugin-gradle:3.0.0”  
> }  
> }  
> apply plugin: ‘com.diffplug.gradle.spotless’

Any idea why ? maybe this is easy but I search the web and found nothing.

Thanks.

---

<div class="post-metadata">

**Author:** ![Bjorn\_Vester](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bjorn_vester/32/7839_2.png) [@Bjorn\_Vester](https://discuss.gradle.org/u/Bjorn_Vester)\
**Post date:** [September 12, 2019, 10:52am UTC](https://discuss.gradle.org/t/buildscript-plugin-and-multiple-files/33127/2 "2019-09-12T10:52:11Z")

</div>

I think you are hit by a limitation in the way plugin IDs are resolved in an applied build script, which is described in Github issue [1262](https://github.com/gradle/gradle/issues/1262). There are some work-arounds suggested in the comments to that issue.

---

<div class="post-metadata">

**Author:** ![Schalk\_Cronje](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/schalk_cronje/32/6511_2.png) [@Schalk\_Cronje](https://discuss.gradle.org/u/Schalk_Cronje)\
**Post date:** [September 13, 2019, 6:20am UTC](https://discuss.gradle.org/t/buildscript-plugin-and-multiple-files/33127/3 "2019-09-13T06:20:35Z")

</div>

There are definite and confusing limitations w.r.t to what you have attempted.

In your case you are going to be better off by hiding as much as you can in buildSrc and then just apply custom plugins that you have created in buildSrc.

---

<div class="post-metadata">

**Author:** ![MickD](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mickd/32/5382_2.png) [@MickD](https://discuss.gradle.org/u/MickD)\
**Post date:** [September 24, 2019, 7:28am UTC](https://discuss.gradle.org/t/buildscript-plugin-and-multiple-files/33127/4 "2019-09-24T07:28:01Z")

</div>

Thanks you all for your answears.

The simplest way for me is to put the same piece of code everywhere ☹
