Gradle Dynamically Generate Tasks -
this first attempt using clojure , i'm attempting generate tasks in build.gradle file. i'm encountering complication errors such as:
* where:
build file '/users/austin/repositories/test/build.gradle' line: 47
* went wrong:
a problem occurred evaluating root project 'test'. cannot set value of read-only property 'src' task ':downloaddriverfirefox' of type de.undercouch.gradle.tasks.download.download.
i'm it's inexperience groovy language, use pointers i'm going wrong.
ext { // drivers want 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 -> tasks.create(name: 'downloaddriver'+"${driver}", type: download) { src = path dest ext.driverdest overwrite true } } driverssrc.each {driver -> tasks.create(name: 'unzipdriver'+"${driver}", dependson: 'downloaddriver'+"${driver}", type: copy) { ziptree(file('downloaddriver'+"${driver}").dest) builddir/'webdrivers' } }
things have done:
- cleaned map store data
- since using plugin: https://github.com/michel-kraemer/gradle-download-task, had make sure tasks used correctly
- since have tar, have use
tartree
ziptree
please try this:
buildscript { repositories { jcenter() } dependencies { classpath "de.undercouch:gradle-download-task:3.2.0" } } allprojects { repositories { jcenter() } } import de.undercouch.gradle.tasks.download.download apply plugin: "de.undercouch.download" ext { driverssrc = [ "firefox": "https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-macos.tar.gz", "chrome" : "https://chromedriver.storage.googleapis.com/2.29/chromedriver_mac64.zip" ] driverdest = "${builddir}/webdrivers" } driverssrc.each { driver, path -> def filedest = new file(driverdest, new file(path).getname()) tasks.create(name: "downloaddriver${driver}", type: download) { src path dest filedest overwrite true } tasks.create(name: "unzipdriver${driver}", dependson: "downloaddriver${driver}", type: copy) { path.endswith("zip") ? ziptree(file(filedest)) : tartree(file(filedest)) driverdest } }
to run tasks:
./gradlew unzipdriverfirefox unzipdriverchrome*
Comments
Post a Comment