-
Notifications
You must be signed in to change notification settings - Fork 1
/
osSpecificDownloads.gradle
107 lines (87 loc) · 3.3 KB
/
osSpecificDownloads.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Adapted to this demo from https://github.com/geb/geb-example-cucumber-jvm
import org.apache.tools.ant.taskdefs.condition.Os
import org.apache.commons.io.FileUtils
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "commons-io:commons-io:2.4"
}
}
task downloadChromeDriver {
def outputFile = file("$buildDir/webdriver/chromedriver.zip")
inputs.property("chromeDriverVersion", chromeDriverVersion)
outputs.file(outputFile)
doLast {
def driverOsFilenamePart
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
driverOsFilenamePart = "win32"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
driverOsFilenamePart = "mac64"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
driverOsFilenamePart = Os.isArch("amd64") ? "linux64" : "linux32"
}
FileUtils.copyURLToFile(new URL("http://chromedriver.storage.googleapis.com/${chromeDriverVersion}/chromedriver_${driverOsFilenamePart}.zip"), outputFile)
}
}
task unzipChromeDriver(type: Copy) {
def outputDir = file("$buildDir/webdriver/chromedriver")
dependsOn downloadChromeDriver
outputs.dir(outputDir)
from(zipTree(downloadChromeDriver.outputs.files.singleFile))
into(outputDir)
}
task downloadPhantomJs {
def osFilenamePart
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
osFilenamePart = "windows.zip"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
osFilenamePart = "macosx.zip"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
osFilenamePart = Os.isArch("amd64") ? "linux-x86_64.tar.bz2" : "linux-i686.tar.bz2"
}
def filename = "phantomjs-$phantomJsVersion-$osFilenamePart"
def outputFile = file("$buildDir/webdriver/$filename")
inputs.property("phantomJsVersion", phantomJsVersion)
outputs.file(outputFile)
doLast {
FileUtils.copyURLToFile(new URL("https://bitbucket.org/ariya/phantomjs/downloads/$filename"), outputFile)
}
}
task unzipPhantomJs(type: Copy) {
def outputDir = file("$buildDir/webdriver/phantomjs")
dependsOn downloadPhantomJs
outputs.dir(outputDir)
def archive = downloadPhantomJs.outputs.files.singleFile
from(Os.isFamily(Os.FAMILY_MAC) || Os.isFamily(Os.FAMILY_WINDOWS) ? zipTree(archive) : tarTree(archive))
into(outputDir)
eachFile { FileCopyDetails fcp ->
fcp.relativePath = new RelativePath(!fcp.directory, *fcp.relativePath.segments[1..-1])
}
}
task downloadFirefox {
def osFilenamePart
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
osFilenamePart = "win32.zip"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
osFilenamePart = "macos.tar.gz"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
osFilenamePart = Os.isArch("amd64") ? "-linux32.tar.gz" : "-linux64.tar.gz"
}
def filename = "geckodriver-v$firefoxDriverVersion-$osFilenamePart"
def outputFile = file("$buildDir/webdriver/$filename")
inputs.property("firefoxDriverVersion", firefoxDriverVersion)
outputs.file(outputFile)
doLast {
FileUtils.copyURLToFile(new URL("https://github.com/mozilla/geckodriver/releases/download/v$firefoxDriverVersion/$filename"), outputFile)
}
}
task unzipFirefox(type: Copy) {
def outputDir = file("$buildDir/webdriver/geckodriver")
dependsOn downloadFirefox
outputs.dir(outputDir)
def archive = downloadFirefox.outputs.files.singleFile
from(Os.isFamily(Os.FAMILY_MAC) || Os.isFamily(Os.FAMILY_WINDOWS) ? tarTree(resources.gzip(archive)) : zipTree(archive))
into(outputDir)
}