# Adding plugin to gradle default classpath

**URL:** <https://discuss.gradle.org/t/adding-plugin-to-gradle-default-classpath/5777>\
**Category:** Old Forum Archive\
**Created:** [May 13, 2014, 8:17pm UTC](https://discuss.gradle.org/t/adding-plugin-to-gradle-default-classpath/5777 "2014-05-13T20:17:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricardo\_Mayerhofer](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@Ricardo\_Mayerhofer](https://discuss.gradle.org/u/Ricardo_Mayerhofer)\
**Post date:** [May 13, 2014, 8:17pm UTC](https://discuss.gradle.org/t/adding-plugin-to-gradle-default-classpath/5777/1 "2014-05-13T20:17:00Z")

</div>

Hi all,

Is there a way to add a given plugin to gradle default classpath? Currently my aproach consists of copying the plugin jar to a folder and reference that folder in the build script.

e.g.

apply plugin: DeployPlugin

buildscript {

dependencies {

classpath fileTree(dir: ‘lib’, include: ‘\*.jar’)

}

}

I’m looking for a aproach where there is no need to reference the jar in the build script. I’ve tried to copy it to GRADLE\_HOME/lib or GRADLE\_HOME/lib/plugins, but it didn’t work ☹

Thx.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 13, 2014, 11:12pm UTC](https://discuss.gradle.org/t/adding-plugin-to-gradle-default-classpath/5777/2 "2014-05-13T23:12:00Z")

</div>

You could put the (slightly modified) ‘buildscript’ block into ‘~/.gradle/init.gradle’, or into ‘init.d/init.gradle’ inside your Gradle distribution.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Mayerhofer](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@Ricardo\_Mayerhofer](https://discuss.gradle.org/u/Ricardo_Mayerhofer)\
**Post date:** [May 13, 2014, 11:25pm UTC](https://discuss.gradle.org/t/adding-plugin-to-gradle-default-classpath/5777/3 "2014-05-13T23:25:00Z")

</div>

Hi, Thanks for your response. I’ve tried to create a loadPlugin.gradle and moved it to init.d. I’ve got the following error:

A problem occurred evaluating initialization script. You can’t change a configuration which is not in unresolved state!

Here goes the script body: buildscript {

dependencies {

classpath fileTree(dir: “/opt/gradle-1.3/lib/custom-plugins”, include: “\*.jar”)

} }

I’m using gradle 1.3.

Any idea?

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 13, 2014, 11:30pm UTC](https://discuss.gradle.org/t/adding-plugin-to-gradle-default-classpath/5777/4 "2014-05-13T23:30:00Z")

</div>

Someone is trying to configure a configuration after it has been resolved, which isn’t allowed. Typically this happens when a configuration is resolved too early, such as someone iterating over the resolved files in the configuration phase, rather than the execution phase. The full error message should give some more hints.
