# Why it doesn't download dependency? this is code from custom plugin

**URL:** <https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194>\
**Category:** Old Forum Archive\
**Created:** [January 7, 2013, 4:08pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194 "2013-01-07T16:08:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zbyszek\_Sokolowski](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zbyszek_sokolowski/32/384_2.png) [@Zbyszek\_Sokolowski](https://discuss.gradle.org/u/Zbyszek_Sokolowski)\
**Post date:** [January 7, 2013, 4:08pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/1 "2013-01-07T16:08:00Z")

</div>

```gradle
private void setJSTestDriver(Project project) {
      project.repositories {
      maven { url 'http://local:8081/artifactory/testautomation-ext-local' }
    }
    project.configurations {
      jtestdriver
    }
    project.dependencies {
      jtestdriver 'net.awired.com.googlecode.jstestdriver:jstestdriver:1.3.5'
      }
         project.tasks.add(name: "$runJSTestDriver", type: JavaExec, group: 'Sonar utils', description: 'Run JSTestDriver') {
      dependsOn project.configurations.jtestdriver
      ext.jsTestDriverResultsDir = "/jstestdriver"
      inputs.source "wwwroot"
      main = 'com.google.jstestdriver.Main'
      classpath {
        [
                project.configurations.jtestdriver,
                project.files({project.sonarutils.js.sourceDirs}),
                project.files({project.sonarutils.js.testDirs}),
                project.files("${project.getBuildDir()}" + ext.jsTestDriverResultsDir),
        ]
        args =
          [
                  "--config", "jsTestDriver.conf",
                  "--port", "9876",
                  "--browser", "${project.sonarutils.js.browserPath}",
                  "--tests","all",
                  "--testOutput", "${project.getBuildDir()}" + ext.jsTestDriverResultsDir,
                  //"--runnerMode", "DEBUG",
                  "--verbose"
          ]
      }
    }
    project.tasks.getAt(DevLanguage.JAVASCRIPT.getTaskName()).dependsOn(project.tasks.getByName(runJSTestDriver ))
  }

```

I suppose that it should download a JSTestdriver from repo when I trigger a task but something escapes me. Could you help me?

---

<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:** [January 7, 2013, 8:40pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/2 "2013-01-07T20:40:00Z")

</div>

The ‘args =’ shouldn’t be inside the closure passed to ‘classpath’.

---

<div class="post-metadata">

**Author:** ![evgenyg](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/evgenyg/32/155_2.png) [@evgenyg](https://discuss.gradle.org/u/evgenyg)\
**Post date:** [January 7, 2013, 9:00pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/3 "2013-01-07T21:00:00Z")

</div>

‘build.gradle’:

repositories

{ mavenCentral() }

configurations { jtestdriver }

dependencies

{ jtestdriver ‘junit:junit:4.11’ }

task runJSTestDriver( dependsOn: configurations.jtestdriver ) \<\< {

[//configurations.jtestdriver.files](https://configurations.jtestdriver.files)

}

Have to uncomment “configurations.jtestdriver.files” to make it download the dependency. Is depending on configuration really works? Javadoc mentions [“other tasks”](http://gradle.org/docs/current/javadoc/org/gradle/api/Task.html#dependencies).

---

<div class="post-metadata">

**Author:** ![Tye\_Howard1](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@Tye\_Howard1](https://discuss.gradle.org/u/Tye_Howard1)\
**Post date:** [January 7, 2013, 9:12pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/4 "2013-01-07T21:12:00Z")

</div>

You can force the resolve using something like this:

```gradle
private void setJSTestDriver(Project project) {
    project.repositories { mavenCentral() }
    project.configurations { jtestdriver }
    project.dependencies {
    jtestdriver 'junit:junit:3.8.1'
  }
    project.tasks.add(name: "runJSTestDriver", description: 'Run JSTestDriver') {
    }
    project.tasks["runJSTestDriver"].doFirst {
        project.configurations.jtestdriver.resolve()
    }
}

```

---

<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:** [January 7, 2013, 9:23pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/5 "2013-01-07T21:23:00Z")

</div>

It works, but not in the way you expect it to. Depending on a ‘Buildable’ (like a ‘Configuration’) adds a task dependency on all tasks tracked by the ‘Buildable’. In your case, since the configuration only contains external dependencies, this amounts to zero tasks.

Why do you need to enforce the resolve? As soon as the configuration gets queried for its files (in one way or another), it will get resolved anyway. And if it never gets queried, why would it need to get resolved?

---

<div class="post-metadata">

**Author:** ![evgenyg](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/evgenyg/32/155_2.png) [@evgenyg](https://discuss.gradle.org/u/evgenyg)\
**Post date:** [January 8, 2013, 1:01am UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/6 "2013-01-08T01:01:00Z")

</div>

Thanks! I was trying to reproduce the original question scenario (if I understood it correctly) - force dependencies download when the task starts.

---

<div class="post-metadata">

**Author:** ![Zbyszek\_Sokolowski](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zbyszek_sokolowski/32/384_2.png) [@Zbyszek\_Sokolowski](https://discuss.gradle.org/u/Zbyszek_Sokolowski)\
**Post date:** [January 8, 2013, 8:25am UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/7 "2013-01-08T08:25:00Z")

</div>

thank you, it was done because of hurry, I didn’t noticed a braces in incorrect place.

---

<div class="post-metadata">

**Author:** ![Zbyszek\_Sokolowski](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zbyszek_sokolowski/32/384_2.png) [@Zbyszek\_Sokolowski](https://discuss.gradle.org/u/Zbyszek_Sokolowski)\
**Post date:** [January 8, 2013, 10:50am UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/8 "2013-01-08T10:50:00Z")

</div>

one more question Peter from above snippet of code how to set lazily from extensions, this below doesn’t work

```gradle
"--browser", "${project.sonarutils.js.browserPath}",

```

---

<div class="post-metadata">

**Author:** ![Zbyszek\_Sokolowski](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zbyszek_sokolowski/32/384_2.png) [@Zbyszek\_Sokolowski](https://discuss.gradle.org/u/Zbyszek_Sokolowski)\
**Post date:** [January 8, 2013, 12:43pm UTC](https://discuss.gradle.org/t/why-it-doesnt-download-dependency-this-is-code-from-custom-plugin/7194/9 "2013-01-08T12:43:00Z")

</div>

I figured out something like this and this works:

```gradle
"--browser", "${->project.sonarutils.js.browserPath}",

```
