# Creating a Gradle plugin with a dependency on another (external) plugin?

**URL:** <https://discuss.gradle.org/t/creating-a-gradle-plugin-with-a-dependency-on-another-external-plugin/3287>\
**Category:** Old Forum Archive\
**Created:** [April 10, 2012, 5:03pm UTC](https://discuss.gradle.org/t/creating-a-gradle-plugin-with-a-dependency-on-another-external-plugin/3287 "2012-04-10T17:03:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vic\_jugador](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vic\_jugador](https://discuss.gradle.org/u/vic_jugador)\
**Post date:** [April 10, 2012, 5:03pm UTC](https://discuss.gradle.org/t/creating-a-gradle-plugin-with-a-dependency-on-another-external-plugin/3287/1 "2012-04-10T17:03:00Z")

</div>

I want to create a plugin that automatically applies other (external plugins). This requires setting the buildscript dependency for the plugin before I call “apply plugin”. However it seems like I can’t add buildscript dependencies in a plugin or I get: You can’t change a configuration which is not in unresolved state!

Is there a solution to this ?

My sample (non-working) code:

```gradle
import org.gradle.api.Project
import org.gradle.api.Plugin
class SamplePlugin implements Plugin<Project>{
  void apply(Project project) {
      project.buildscript.dependencies.add("classpath","net.sourceforge.cobertura:cobertura:1.9.4.1");
      project.configure(project){
               apply plugin: 'cobertura'
     }
  }
}

```

---

<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:** [April 10, 2012, 10:27pm UTC](https://discuss.gradle.org/t/creating-a-gradle-plugin-with-a-dependency-on-another-external-plugin/3287/2 "2012-04-10T22:27:00Z")

</div>

I’ve already answered here: [http://stackoverflow.com/questions/10081299/creating-a-gradle-plugin-with-a-dependency-on-another-external-plugin](http://stackoverflow.com/questions/10081299/creating-a-gradle-plugin-with-a-dependency-on-another-external-plugin)
