This repository was archived by the owner on Aug 20, 2018. It is now read-only.
forked from mozilla/moz-grid-config
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.xml
199 lines (179 loc) · 7.93 KB
/
build.xml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<project name="selenium-grid" default="launch-node" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<property environment="env"/>
<exec executable="hostname" osfamily="unix" failifexecutionfails="false" outputproperty="env.COMPUTERNAME"/>
<property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/> <!-- Windows vs. Linux -->
<property file="${basedir}/${env.HOSTNAME}.properties" />
<property file="${basedir}/default.properties"/>
<target name="fetch-dependencies">
<mkdir dir="lib"/>
<get src="http://selenium-release.storage.googleapis.com/${selenium.version.major}${selenium.version.suffix}/selenium-server-standalone-${selenium.version.major}.${selenium.version.minor}${selenium.version.suffix}.jar"
dest="lib"
usetimestamp="true"
ignoreerrors="yes"/>
<available file="lib/selenium-server-standalone-${selenium.version.major}.${selenium.version.minor}${selenium.version.suffix}.jar" property="selenium.present"/>
<fail unless="selenium.present" message="Unable to locate lib/selenium-server-standalone-${selenium.version.major}.${selenium.version.minor}${selenium.version.suffix}.jar"/>
</target>
<target name="geckodriver">
<condition property="isWindows" value="true">
<os family="windows" />
</condition>
<condition property="geckodriver.platform" value="macos">
<os family="mac" />
</condition>
<condition property="geckodriver.platform" value="win64">
<isset property="isWindows" />
</condition>
<condition property="geckodriver.platform" value="linux64">
<os family="unix" />
</condition>
<condition property="geckodriver.archive" value="tar.gz">
<not>
<isset property="isWindows" />
</not>
</condition>
<condition property="geckodriver.archive" value="zip">
<isset property="isWindows" />
</condition>
<property name="geckodriver.filename" value="geckodriver-v${geckodriver.version}-${geckodriver.platform}"/>
<get src="https://github.com/mozilla/geckodriver/releases/download/v${geckodriver.version}/${geckodriver.filename}.${geckodriver.archive}" dest="lib" usetimestamp="true" ignoreerrors="yes"/>
<gunzip src="lib/${geckodriver.filename}.${geckodriver.archive}" dest="lib" unless:set="isWindows"/>
<unzip src="lib/${geckodriver.filename}.${geckodriver.archive}" dest="lib/${geckodriver.filename}" if:set="isWindows"/>
<untar src="lib/${geckodriver.filename}.tar" dest="lib/${geckodriver.filename}" unless:set="isWindows"/>
<delete file="lib/${geckodriver.filename}.tar" unless:set="isWindows"/>
<condition property="geckodriver.binary" value="lib/${geckodriver.filename}/geckodriver">
<not>
<isset property="isWindows" />
</not>
</condition>
<condition property="geckodriver.binary" value="lib/${geckodriver.filename}/geckodriver.exe">
<isset property="isWindows" />
</condition>
<chmod file="lib/${geckodriver.filename}/geckodriver" perm="+x" unless:true="isWindows"/>
<echo>geckodriver.version: ${geckodriver.version}</echo>
<echo>geckodriver.platform: ${geckodriver.platform}</echo>
<echo>geckodriver.archive: ${geckodriver.archive}</echo>
<echo>geckodriver.filename: ${geckodriver.filename}</echo>
<echo>geckodriver.binary: ${geckodriver.binary}</echo>
</target>
<target name="set-config">
<echo>os.name: ${os.name}</echo>
<condition property="node.configuration.file" value="mac.json">
<contains string="${os.name}" substring="mac" casesensitive="false"/>
</condition>
<condition property="node.configuration.file" value="winvista.json">
<os name="Windows Vista"/>
</condition>
<condition property="node.configuration.file" value="win7.json">
<os name="Windows 7"/>
</condition>
<property name="node.configuration.file" value="default.json"/>
<echo>node.configuration.file: ${node.configuration.file}</echo>
</target>
<target name="set-hosts">
<!-- set the production hub host for the production environment -->
<condition property="hub.host" value="${production.hub.host}">
<matches pattern="^production$" string="${env}"/>
</condition>
<!-- set the staging hub host for the staging environment -->
<condition property="hub.host" value="${staging.hub.host}">
<matches pattern="^staging$" string="${env}"/>
</condition>
<!-- otherwise set to localhost (unless overridden) -->
<property name="hub.host" value="localhost"/>
<!-- if the hub is running on localhost then so must the node be -->
<condition property="node.host" value="localhost">
<matches pattern="localhost" string="${hub.host}"/>
</condition>
<!-- otherwise set to the hostname -->
<property name="node.host" value="${env.HOSTNAME}"/>
<echo>hub.host: ${hub.host}</echo>
<echo>node.host: ${node.host}</echo>
</target>
<path id="selenium.classpath">
<pathelement path="${basedir}/"/>
<fileset dir="${basedir}/lib">
<include name="selenium-server-standalone-${selenium.version.major}.${selenium.version.minor}${selenium.version.suffix}.jar"/>
</fileset>
<pathelement path="${java.class.path}/"/>
</path>
<!-- debug target to show variables -->
<target name="debug">
<echoproperties/>
</target>
<target name="launch-hub"
description="Launch Selenium Hub"
depends="fetch-dependencies">
<java classname="${selenium.classname}"
classpathref="selenium.classpath"
fork="true"
failonerror="true">
<arg value="-role"/>
<arg value="hub"/>
<arg value="-hubConfig"/>
<arg value="hub_configuration.json"/>
</java>
</target>
<target name="launch-hub-debug"
description="Launch Selenium Hub in debug mode"
depends="fetch-dependencies">
<java classname="${selenium.classname}"
classpathref="selenium.classpath"
fork="true"
failonerror="true">
<arg value="-role"/>
<arg value="hub"/>
<arg value="-hubConfig"/>
<arg value="hub_configuration.json"/>
<arg value="-debug"/>
<arg value="-log"/>
<arg value="hub.log"/>
</java>
</target>
<target name="launch-node"
description="Launch Selenium Node"
depends="fetch-dependencies, geckodriver, set-config, set-hosts">
<java classpathref="selenium.classpath"
classname="${selenium.classname}"
fork="true"
failonerror="true">
<sysproperty key="http.nonProxyHosts" value="${hub.host}"/>
<sysproperty key="webdriver.gecko.driver" value="${geckodriver.binary}"/>
<sysproperty key="webdriver.firefox.marionette" value="false"/>
<arg value="-role"/>
<arg value="node"/>
<arg value="-id"/>
<arg value="${env.HOSTNAME}"/>
<arg value="-hub"/>
<arg value="http://${hub.host}:${hub.port}/grid/register"/>
<arg value="-host"/>
<arg value="${node.host}"/>
<arg value="-nodeConfig"/>
<arg value="${node.configuration.file}"/>
</java>
</target>
<target name="launch-node-debug"
description="Launch Selenium Node in debug mode"
depends="fetch-dependencies, geckodriver, set-config, set-hosts">
<java classpathref="selenium.classpath"
classname="${selenium.classname}"
fork="true"
failonerror="true">
<sysproperty key="http.nonProxyHosts" value="${hub.host}"/>
<sysproperty key="webdriver.gecko.driver" value="${geckodriver.binary}"/>
<sysproperty key="webdriver.firefox.marionette" value="false"/>
<arg value="-role"/>
<arg value="node"/>
<arg value="-id"/>
<arg value="${env.HOSTNAME}"/>
<arg value="-hub"/>
<arg value="http://${hub.host}:${hub.port}/grid/register"/>
<arg value="-host"/>
<arg value="${node.host}"/>
<arg value="-nodeConfig"/>
<arg value="${node.configuration.file}"/>
<arg value="-debug"/>
<arg value="-log"/>
<arg value="node.log"/>
</java>
</target>
</project>