-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.xml
238 lines (177 loc) · 11.1 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!DOCTYPE project>
<project name="selenium-tests" basedir="." default="main" xmlns:ivy="antlib:org.apache.ivy.ant">
<!--
A good post to guide to create a build file:
http://stackoverflow.com/questions/20382287/integrating-jacoco-in-sonar-using-ant/20413444#20413444
-->
<!--========================================================================
Property Defaults
Any of these properties can be overridden in either build.properties or override.properties
=====================================================================-->
<!-- Global properties -->
<property environment="env" />
<property file="${basedir}/build.properties" description="Properties customized for your particular project belong in this file." />
<!-- Compile properties -->
<property name="bin.dir" value="${basedir}/bin" description="Base directory for all non-dist build output" />
<property name="src.java.dir" value="${basedir}/src/main/java" description="Source code of PageFactory for Selenium tests." />
<property name="src.test.java.dir" value="${basedir}/src/test/java" description="Source code of test to run." />
<property name="src.test.suite.dir" value="${basedir}/src/test/resources/TestNG_suites" description="Location of all xml files." />
<property name="build.dir" value="${basedir}/build" description="Build directory." />
<property name="classes.dir" value="${build.dir}/classes" description="Classes directory created during compilation." />
<property name="test.output.dir" value="${basedir}/test-output" description="Target directory." />
<property name="lib.dir" value="${basedir}/lib" description="Directory that hosts Jar files required to compile project source." />
<property name="lib.ext.dir" value="${basedir}/lib/ext" description="Directory that hosts Jar files required to compile project source. (IVY will populate this directory with required jars)" />
<!-- Ivy properties -->
<property name="ivy.settingsurl" value="file:${basedir}/ivysettings.xml" description="URL to the (common) ivysettings.xml. This file is required by the build to configure IVY. Note you must escape the ':' if this property exists in a .properties file." />
<property name="ivy.file" value="ivy.xml" description="The name of the IVY xml file defining your project's dependencies" />
<property name="ivy.artifact.group" value="pentaho" description="IVY metadata describing the originating company or organization" />
<property name="ivy.default.ivy.user.dir" value="${basedir}" description="Dir of ivy cache" />
<!-- TEST propertis -->
<property name="test.html.reports.dir" value="${basedir}/reports-html" description="Directory to drag reports for the selenium html scripts" />
<property name="test.java.reports.dir" value="${basedir}/reports-java" description="Directory to drag reports" />
<property name="test.testng.suite.file" value="SmokeTests-CE.xml" />
<taskdef resource="testngtasks" classpath="${lib.dir}/testng-latest.jar" />
<!-- CLASSPATH FOR Selenium Tests -->
<path id="test.java.classpath">
<fileset dir="${lib.ext.dir}" includes="**/*" />
<pathelement location="${classes.dir}" />
</path>
<!--========================================================================
bootstrap
Download, create and generate the necessary artifacts to build the project.
=====================================================================-->
<available classname="org.apache.ivy.Main" property="ivy.installed" />
<target name="bootstrap" description="Install ivy" unless="ivy.installed">
<mkdir dir="${user.home}/.ant/lib" />
<get dest="${user.home}/.ant/lib/ivy.jar" src="http://mirrors.fe.up.pt/pub/apache/ant/ivy/2.4.0/maven2/2.4.0/ivy-2.4.0.jar" />
<fail message="Ivy has been installed. Run the build again." />
</target>
<!--========================================================================
init
Create the necessary directories for the project.
=====================================================================-->
<target name="init" depends="resolve" description="Install ivy">
<echo message="Create the necessary directories for the project."/>
<mkdir dir="${classes.dir}" />
<mkdir dir="${test.java.reports.dir}" />
<ivy:settings url="${ivy.settingsurl}" />
</target>
<!--========================================================================
compile
Compile the script tests in Java
=====================================================================-->
<target name="compile" depends="init">
<javac srcdir="${src.java.dir};${src.test.java.dir}" destdir="${classes.dir}" fork="yes" debug="true" includeAntRuntime="false" classpathref="test.java.classpath" nowarn="true" encoding="UTF-8">
<!--<compilerarg value="-Xlint"/>-->
</javac>
</target>
<!--========================================================================
main
Let's clean project, compile it, prepare environment and run the tests.
=====================================================================-->
<target name="main" depends="clean,compile,run"/>
<!--========================================================================
run
This process shall execute Selenium Java tests.
=====================================================================-->
<target name="run">
<testng classpathref="test.java.classpath" outputdir="${test.java.reports.dir}">
<!-- The JVM arg is need to configure the logging system -->
<jvmarg value="-Dlog4j.configurationFile=./log4j2.xml" />
<xmlfileset dir="${src.test.suite.dir}" includes="${test.testng.suite.file}" />
</testng>
</target>
<!--========================================================================
resolve
Resolve all necessary dependencies for the project.
=====================================================================-->
<target name="resolve" depends="bootstrap,resolve-build" description="Retrieves all the dependent libraries." />
<!--========================================================================
resolve-build
Using ivy and the dependencies for the project (defined in the ivy.xml
file), this task will retrieve the needed files and place them into
the defined directories.
=====================================================================-->
<target name="resolve-build" description="Retrieves all 'build' dependent libraries">
<echo message="Resolve dependencies 'build'." />
<ivy:resolve file="${ivy.file}" conf="build" />
<ivy:retrieve pattern="${lib.ext.dir}/[artifact](-[classifier]).[ext]" />
</target>
<!--========================================================================
ivy-clean-all
Clean the cache and local.
=====================================================================-->
<target name="ivy-clean-all" depends="ivy-clean-cache,ivy-clean-local" />
<!--========================================================================
ivy-clean-local
Completely cleans your local repository of any files published locally
by way of publish-local.
WARNING: this is a global action and will affect other IVY projects
currently referencing a locally published dependency.
=====================================================================-->
<target name="ivy-clean-local">
<delete dir="${ivy.local.default.root}/" />
</target>
<!--========================================================================
ivy-clean-cache
Cleans the IVY cache. You are erasing IVY's memory. Run this if you
want to force IVY to go fetch all your project dependencies from scratch.
WARNING: this will affect all IVY projects, not just the current workspace.
=====================================================================-->
<target name="ivy-clean-cache">
<ivy:cleancache />
</target>
<!--========================================================================
clean-common
Removes resources share by Selenium HTML and JAVA scripts.
=====================================================================-->
<target name="clean-common" description="Detect common resources.">
<delete dir="${lib.ext.dir}" />
<delete dir="${test.output.dir}" />
<delete dir="${bin.dir}" />
<delete dir="${build.dir}" />
<delete>
<fileset dir="${basedir}" includes="junit*.properties" />
</delete>
</target>
<!--========================================================================
clean-html
Removes regarding the target 'test-html'.
=====================================================================-->
<target name="clean-html" description="Cleans all the files generated from ctools">
<delete dir="${test.html.reports.dir}" />
</target>
<!--========================================================================
clean-java
Removes regarding the target 'test-java'.
=====================================================================-->
<target name="clean-java" description="Cleans the directories created when build selenium java tests">
<delete dir="${test.java.reports.dir}" />
</target>
<!--=======================================================================
clean
Removes all the files generated during the execution test for html and
java's selenium tests.
=====================================================================-->
<target name="clean" depends="clean-common,clean-html,clean-java" description="Cleans all the files generated on selenium html and java tests" />
<!--========================================================================
clean-all
Removes all the files generated from build processes and ivy-downloaded jars.
=====================================================================-->
<target name="clean-all" depends="clean, ivy-clean-all" description="Cleans all the files generated from a build as well IVY-downloaded jars" />
<!--========================================================================
Macro usage to start or stop a service.
parameters:
action - The name of the library (the filename w/o extension)
service - The URL from which the library will be downloaded
=====================================================================-->
<macrodef name="service">
<attribute name="service" />
<attribute name="action" />
<sequential>
<exec executable="cmd.exe">
<arg line="/c net @{action} '@{service}'" />
</exec>
</sequential>
</macrodef>
</project>