forked from operasoftware/operaprestodriver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
213 lines (183 loc) · 8.2 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
<?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="jar.filename" value="operadriver-${version}.jar" />
<property name="jar.path" value="pkg/${jar.filename}" />
<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>
<property name="test.dir.path" value="bin" />
<property name="test.output.path" value="test-output" />
<property name="test.report.path" value="test-reports" />
<!-- Targets -->
<!-- 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" />
</target>
<!-- Compile all classes after cleaning -->
<target name="compile" description="Compile all the source files">
<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.5" target="1.5" debug="true" destdir="bin" includeantruntime="false">
<src path="src" />
<classpath refid="classpath.path" />
</javac>
</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>
<target name="jar_internal" description="Make an internal JAR allowing click of disabled elements">
<replace file="src/com/opera/core/systems/scope/internal/OperaFlags.java" token="ENABLE_CHECKS = true" value="ENABLE_CHECKS = false" />
<antcall target="jar" inheritAll="false">
<param name="version" value="${version}-internal" />
</antcall>
<replace file="src/com/opera/core/systems/scope/internal/OperaFlags.java" token="ENABLE_CHECKS = false" value="ENABLE_CHECKS = true" />
</target>
<!-- Compile any modified classes including test classes -->
<target name="compile_tests" depends="jar">
<javac source="1.5" target="1.5" 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.5.0/docs/api/"/>
</javadoc>
</target>
<target name="example" description="Run the simple example" depends="jar">
<javac source="1.5" target="1.5" debug="true" includeantruntime="false">
<classpath refid="test.classpath.path" />
<src path="examples/simple" />
</javac>
<java classname="Example" fork="yes">
<classpath refid="test.classpath.path" />
<classpath location="examples/simple" />
</java>
</target>
<target name="release" description="Generate a ZIP for release including the JAR, docs and examples" 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 the examples -->
<zipfileset prefix="${release-zip.name}/examples" dir="examples/" />
<!-- 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>