# buildSrc/build.gradle vs buildscript block

**URL:** <https://discuss.gradle.org/t/buildsrc-build-gradle-vs-buildscript-block/25024>\
**Category:** Help/Discuss\
**Created:** [December 5, 2017, 6:09pm UTC](https://discuss.gradle.org/t/buildsrc-build-gradle-vs-buildscript-block/25024 "2017-12-05T18:09:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliverdain](https://avatars.discourse-cdn.com/v4/letter/o/cab0a1/32.png) [@oliverdain](https://discuss.gradle.org/u/oliverdain)\
**Post date:** [December 5, 2017, 6:09pm UTC](https://discuss.gradle.org/t/buildsrc-build-gradle-vs-buildscript-block/25024/1 "2017-12-05T18:09:21Z")

</div>

I posted this on StackOverflow ([https://stackoverflow.com/q/47644319/1431244](https://stackoverflow.com/q/47644319/1431244)) but didn’t get a response. Hoping someone here can clarify:

We have a Gradle build that includes a buildSrc with some custom plugins. Those plugins apply yet other plugins. For example, our plugin applies com.android.tools.build:gradle. For annotation processing that library needs to be on Gradle’s classpath during compilation. So, putting this in our main build.gradle works:

```gradle
buildscript {
    repositories {
        google()
    }
    dependencies {
       classpath "com.android.tools.build:gradle:$gToolsVersion"
    }
}

```

However, that means that for a user to apply this plugin they must (1) apply our plugin and (2) add that buildscript boilerplate. It seems like that shouldn’t be necessary. We can also add a `project.buildscript` block inside our plugin but that too seems unnecessary and, due to this bug is problematic: [https://developer.android.com/studio/build/gradle-plugin-3-0-0.html?utm\_source=android-studio#known\_issues](https://developer.android.com/studio/build/gradle-plugin-3-0-0.html?utm_source=android-studio#known_issues).

I added the com.android.tools.build:gradle dependency to buildSrc/build.gradle as a runtime dependency. It seems like that should work: I thought that tells Gradle that in order to run my plugin that library (and its dependencies) need to be on the classpath. However, gradle buildEnvironment (and the fact that our build fails) makes it clear that’s not the case.

So, questions:

1. What’s the difference between a runtime dependency specified in buildSrc/build.gradle and a classpath dependency specified in a buildscript block in a regular build.gradle?
2. How can I arrange things so that users can apply the plugin from buildSrc and not have to also add the buildscript block to their build.gradle?

---

<div class="post-metadata">

**Author:** ![oliverdain](https://avatars.discourse-cdn.com/v4/letter/o/cab0a1/32.png) [@oliverdain](https://discuss.gradle.org/u/oliverdain)\
**Post date:** [December 14, 2017, 1:06am UTC](https://discuss.gradle.org/t/buildsrc-build-gradle-vs-buildscript-block/25024/2 "2017-12-14T01:06:15Z")

</div>

Does nobody know the answer to this??

I just put a bounty on the StackOverflow post so now’s your chance to get 50 reputation points!

---

<div class="post-metadata">

**Author:** ![Chris\_Dore](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/chris_dore/32/7592_2.png) [@Chris\_Dore](https://discuss.gradle.org/u/Chris_Dore)\
**Post date:** [August 21, 2018, 5:27am UTC](https://discuss.gradle.org/t/buildsrc-build-gradle-vs-buildscript-block/25024/3 "2018-08-21T05:27:37Z")

</div>

Did you ever get your buildSrc plugin working?
