title: Gradle Dynamically Generate Tasks
body: <p>This is my first attempt using clojure and I'm attempting to generate some tasks in my build.gradle file.  I'm encountering complication errors such as:</p>
  
  <blockquote>
    <p>* Where:</p>
    
    <p>Build file '/Users/austin/Repositories/test/build.gradle' line: 47</p>
    
    <p>* What went wrong:</p>
    
    <p>A problem occurred evaluating root project 'test'.
       Cannot set the value of read-only property 'src' for task ':downloadDriverfirefox' of type de.undercouch.gradle.tasks.download.Download.</p>
  </blockquote>
  
  <p>I'm fairly certain it's just my inexperience with the groovy language, but I could really use some pointers as to where I'm going wrong.</p>
  
  <pre><code>ext {
  // The drivers we want to use
  drivers = ["firefox", "chrome"]
  
  driversSrc = [:]
  driversSrc['firefox'] = 'https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-macos.tar.gz'
  driversSrc['chrome'] = 'https://chromedriver.storage.googleapis.com/2.29/chromedriver_mac64.zip'
  
  driverDest = new File("${buildDir}/webdrivers")
  }
  
  import org.gradle.api.tasks.*
  import de.undercouch.gradle.tasks.download.Download
  
  driversSrc.each { driver, path -&gt;
  tasks.create(name: 'downloadDriver'+"${driver}", type: Download) {
      src = path
      dest ext.driverDest
      overwrite true
  }
  }
  
  driversSrc.each {driver -&gt;
  tasks.create(name: 'unzipDriver'+"${driver}", dependsOn: 'downloadDriver'+"${driver}", type: Copy) {
      from zipTree(file('downloadDriver'+"${driver}").dest)
      into buildDir/'webdrivers'
  }
  }
  </code></pre>