-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathbuild.xml
238 lines (206 loc) · 9.53 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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="compile" name="OperaDriver">
<!-- Location of the Selenium source. Used to generate docs and
inherit the JavaDoc -->
<property name="selenium.src" value="../selenium/java/client/src" />
<!-- Get version from Git, and output it to the VERSION file.
This file is later copied to other locations. -->
<exec executable="git" outputproperty="version" failifexecutionfails="false">
<arg value="describe" />
<arg value="--dirty" />
<arg value="--always" />
</exec>
<!-- If we can't get the version from git, set a default -->
<property name="version" value="UNKNOWN-VERSION" />
<echo message="${version}" file="VERSION" />
<!-- Variables -->
<property name="test.dir.path" value="bin" />
<property name="test.output.path" value="test-output" />
<property name="test.report.path" value="test-reports" />
<!-- Targets -->
<target name="init" description="Generates VERSION file, sets properties and classpaths">
<!-- Get version from Git, and output it to the VERSION file. This
is later copied to other locations. -->
<exec executable="git" outputproperty="version" failifexecutionfails="false">
<arg value="describe" />
<arg value="--dirty" />
<arg value="--always" />
</exec>
<!-- If we can't get the version from Git, set a default -->
<property name="version" value="UNKNOWN-VERSION" />
<echo message="${version}" file="VERSION" />
<!-- What to call and where to put the JAR -->
<property name="jar.filename" value="operadriver-${version}.jar" />
<property name="jar.path" value="pkg/${jar.filename}" />
<!-- Classpaths for compilation and tests -->
<path id="classpath.path">
<pathelement location="bin" />
<fileset dir="lib" includes="**/*.jar" />
</path>
<path id="test.classpath.path">
<pathelement location="bin" />
<fileset file="${jar.path}"/>
<fileset dir="lib" includes="**/*.jar" />
</path>
</target>
<!-- Delete the bin and pkg dirs -->
<target name="clean" description="Delete all generated files">
<delete dir="bin" />
<delete>
<fileset dir="." includes="**/*.class"/>
<fileset dir="." includes="**/test_apc.txt"/>
</delete>
<delete dir="pkg" />
<delete dir="docs" />
<delete dir="${test.output.path}" />
<delete dir="${test.report.path}" />
<delete dir="release" />
<delete file="VERSION" />
</target>
<!-- Compile all classes after cleaning -->
<target name="compile" description="Compile all the source files" depends="init">
<fileset dir="bin" />
<mkdir dir="bin" />
<copy file="VERSION" todir="bin" />
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch" />
<exclude name="**/*.java" />
</fileset>
</copy>
<javac source="1.6" target="1.6" debug="true" destdir="bin" includeantruntime="false">
<compilerarg value="-Xlint" />
<src path="src" />
<classpath refid="classpath.path" />
</javac>
</target>
<!-- Perform sonar analysis -->
<target name="sonar" depends="compile">
<!-- Add the Sonar task -->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="lib/sonar-ant-task-1.3.jar" />
<!-- This sonar Ant task library can also be put in the ${ANT_HOME\}/lib directory-->
<!-- In such case this classpath node is no more mandatory -->
</taskdef>
<!-- MYSQL -->
<property name="sonar.jdbc.url"
value="jdbc:mysql://ci.qa.oslo.osa:3306/sonar?useUnicode=true&characterEncoding=utf8" />
<property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver" />
<property name="sonar.jdbc.username" value="FILLMEIN" />
<property name="sonar.jdbc.password" value="FILLMEIN" />
<!-- SERVER ON A REMOTE HOST -->
<property name="sonar.host.url" value="http://ci.qa.oslo.osa:9000" />
<!-- list of mandatories Sonar properties -->
<property name="sonar.sources" value="src" />
<property name="sonar.exclusions" value="com/opera/core/systems/scope/protos/*,com/opera/core/systems/runner/launcher/OperaLauncherProtos.java,com/opera/core/systems/OperaAtom.java" />
<!-- list of optional Sonar properties -->
<property name="sonar.projectName" value="OperaDriver" />
<property name="sonar.binaries" value="bin" />
<!-- <property name="sonar.tests" value="list of test source directories separated by a comma" /> -->
<property name="sonar.libraries" value="lib" />
<sonar:sonar key="opera_driver" version="test" xmlns:sonar="antlib:org.sonar.ant"/>
</target>
<!-- Build the jar -->
<target name="jar" description="Make a JAR file including launchers" depends="compile">
<mkdir dir="pkg" />
<jar destfile="${jar.path}">
<fileset dir="bin" includes="**/*.class" />
<fileset dir="bin" includes="**/*.properties" />
<fileset file="VERSION" />
<zipgroupfileset dir="lib" includes="operalaunchers*.jar" />
<manifest>
<attribute name="Main-Class" value="com.opera.core.systems.OperaDriver" />
<attribute name="Implementation-Version" value="${version}" />
</manifest>
</jar>
</target>
<!-- Compile any modified classes including test classes -->
<target name="compile_tests" depends="jar">
<javac source="1.6" target="1.6" debug="true" destdir="bin" includeantruntime="false">
<src path="test" />
<classpath refid="test.classpath.path" />
</javac>
</target>
<target name="compile_protos" description="Compile all the proto/*.proto files into Java classes. Use -Dprotoc=... to specify protoc binary">
<path id="protos.path">
<fileset dir="protos" includes="*.proto" />
</path>
<!-- If the protoc property isn't set, use the default -->
<property name="protoc" value="protoc" />
<exec executable="python" failifexecutionfails="true" failonerror="true">
<arg value="protos/compile.py" />
<arg value="--java_out" />
<arg value="src" />
<arg value="--protoc" />
<arg value="${protoc}" />
<arg pathref="protos.path" />
</exec>
</target>
<!-- Run all junit tests -->
<target name="test" description="Run all tests on the JAR. Pass -Dclass=<classname> to only run one test" depends="jar, compile_tests">
<delete dir="${test.output.path}" />
<mkdir dir="${test.output.path}" />
<delete dir="${test.report.path}" />
<mkdir dir="${test.report.path}" />
<junit fork="yes" haltonfailure="no" printsummary="yes" showoutput="yes" outputtoformatters="no">
<formatter type="xml" usefile="true" />
<classpath refid="test.classpath.path" />
<classpath location="${test.classpath.path}" />
<!-- run all of the tests -->
<batchtest unless="class" todir="${test.output.path}">
<fileset dir="${test.dir.path}" includes="**/*Test.class" />
</batchtest>
<!-- run just one file/class. Happens when -Dfile=<file> is passed -->
<test if="class" todir="${test.output.path}" name="${class}" />
</junit>
<antcall target="test_report" />
</target>
<target name="test_report" description="Generate reports from test XML files">
<junitreport todir="${test.output.path}">
<fileset dir="${test.output.path}"/>
<report todir="${test.report.path}"/>
</junitreport>
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</target>
<!-- Generate the docs. This will output lots of errors and warnings, but
that's okay because they're (mostly) from selenium, not OperaDriver -->
<target name="doc" description="Generate the Javadocs">
<javadoc destdir="docs" doctitle="OperaDriver" access="public" author="true">
<classpath>
<!-- Include all the jars except selenium, as we're getting the docs
straight from the source -->
<dirset dir="lib">
<include name="*.jar"/>
<exclude name="selenium-common.jar"/>
</dirset>
</classpath>
<!-- include our source, and the selenium source so that we can inherit
the javadocs -->
<sourcepath>
<pathelement location="src" />
<pathelement location="${selenium.src}" />
</sourcepath>
<!-- only generate docs for Opera stuff, not selenium as well -->
<package name="com.opera.core.systems.*" />
<excludepackage name="com.opera.core.systems.scope.protos" />
<!-- Link to online selenium documentation, and the Java docs -->
<link href="http://webdriver.googlecode.com/svn/javadoc/"/>
<link href="http://download.oracle.com/javase/1.6.0/docs/api/"/>
</javadoc>
</target>
<target name="release" description="Generate a ZIP for release including the JAR and docs" depends="clean,jar,doc">
<mkdir dir="release" />
<property name="release-zip.name" value="operadriver-${version}" />
<jar destfile="release/${release-zip.name}-source.jar" basedir="src" />
<zip destfile="release/${release-zip.name}.zip">
<!-- Add the docs -->
<zipfileset prefix="${release-zip.name}/docs" dir="docs/" />
<!-- add OperaDriver (source) jar to the zip -->
<zipfileset prefix="${release-zip.name}" dir="pkg" />
<zipfileset prefix="${release-zip.name}" dir="release" includes="${release-zip.name}-source.jar" />
<!-- Add all the jar libs -->
<zipfileset prefix="${release-zip.name}/lib" dir="lib" excludes="junit*.jar"/>
<zipfileset prefix="${release-zip.name}" dir="." includes="README.md CHANGES AUTHORS LICENSE VERSION"/>
</zip>
</target>
</project>