这是我第一次尝试使用Clojure,我试图在build.gradle
文件中生成一些任务,但遇到了复杂化错误,例如:
* Where:
Build file '/Users/austin/Repositories/test/build.gradle' line: 47
* What went wrong:
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.
我相当肯定这只是我对groovy语言缺乏经验,但我真的需要一些指针来指出我哪里出错了。
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 ->
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) {
from zipTree(file('downloadDriver'+"${driver}").dest)
into buildDir/'webdrivers'
}
}
1条答案
按热度按时间kyks70gy1#
我做过的事
tarTree
和zipTree
请尝试以下操作:
要运行任务: