title: Programmatically add dependencies for a Jar task
body: <p>I'm creating a Gradle plugin that must compile the output of the SwaggerCodegen lib (a Java source tree). Inside my apply() function of my plugin, I define a  swaggerClient source set and configuration:</p>
  
  <pre><code>    project.sourceSets {
          swaggerClient {
              java {
                  srcDirs new File(javaGenTask.outputDirectory, 'src/main/java').absolutePath
              }
          }
      }
  
      project.configurations {
          swaggerClient
      }
  </code></pre>
  
  <p>Then, I parse the generated build.gradle file for its dependencies, get a list of strings (with the configurations) and add them to the configuration:</p>
  
  <pre><code>//t instanceof List&lt;String&gt;, with entries in dependency markup such as:
  //io.github.robwin:swagger2markup:0.9.1
  
      project.configurations.getByName('swaggerClient') { Configuration conf -&gt;
          conf.dependencies.addAll t.collect {String s -&gt; project.dependencies.create s}
      }
  </code></pre>
  
  <p>After this I define a Jar-type task:</p>
  
  <pre><code>    project.task('Koos',
              description: 'Generate a java jar using Swagger markup',
              type: Jar,
              dependsOn: javaGenTask) {
          from project.sourceSets.asMap['swaggerClient'].output
      }
  </code></pre>
  
  <p>The javaGenTask is the task that generates the Java source.</p>
  
  <p>When running the task, none of the declared dependencies are there, resulting in compiler 'package &lt;> doesn't exist' errors (resulting in compile failures).</p>