forked from LiveRamp/jack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
executable file
·271 lines (229 loc) · 9.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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<project name="jack" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property name="version" value="0.1.0" />
<!-- pull the database creds from the sys properties -->
<property name="db.user" value="root"/>
<property name="db.pass" value=""/>
<property environment="env" />
<property name="src" location="src" />
<property name="src.java" location="${src}/java" />
<property name="src.java.generated" location="${src}/java/com/rapleaf/hank/generated" />
<property name="build" location="build" />
<property name="build.classes" location="${build}/classes" />
<property name="src.test" location="test" />
<property name="build.test" location="${build}/test" />
<property name="lib" location="lib" />
<property name="doc" location="javadoc"/>
<property name="test.junit.output.format" value="plain"/>
<property name="test.timeout" value="2000000"/>
<property name="test.src.dir" location="${basedir}/test/java"/>
<property name="test.log.dir" value="${build.test}/log"/>
<property name="test.port" value="9090" />
<property name="config.dir" location="${basedir}/config"/>
<property name="jar.file" location="${build}/jack-1.0-SNAPSHOT.jar" />
<fileset id="jars" dir="${lib}" includes="*.jar" />
<path id="maven-ant-tasks.classpath" path="antlib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
<path id="compile.classpath">
<fileset id="jars" dir="${lib}" includes="**/*.jar" />
</path>
<path id="test.classpath">
<path refid="compile.classpath" />
<pathelement location="${build.classes}" />
<pathelement location="${build.test}" />
</path>
<target name="resolve">
<mkdir dir="${lib}"/>
<artifact:dependencies filesetId="deps.fileset">
<pom file="pom.xml"/>
</artifact:dependencies>
<copy todir="lib" flatten="true">
<fileset refid="deps.fileset" />
<mapper classpathref="maven-ant-tasks.classpath"
classname="org.apache.maven.artifact.ant.VersionMapper"
from="${dependency.versions}" to="flatten" />
</copy>
</target>
<target name="select-mysql">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c 'test/select-dbms.sh mysql'" />
</exec>
</target>
<target name="select-postgres">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c 'test/select-dbms.sh postgres'" />
</exec>
</target>
<target name="ensure-dbms-selected" >
<available file="config/database.yml" property="database.yml.root"/>
<available file="test/test_project/database_1/config/database.yml" property="database.yml.db1"/>
<available file="test/test_project/database_2/config/database.yml" property="database.yml.db2"/>
<available file="test/test_project/database_1/Gemfile" property="gemfile.db1"/>
<available file="test/test_project/database_2/Gemfile" property="gemfile.db2"/>
<fail message="No database.yml files were found. Please run ant select-postgres or ant select-mysql first.">
<condition>
<not>
<and>
<isset property="database.yml.root"/>
<isset property="database.yml.db1"/>
<isset property="database.yml.db2"/>
<isset property="gemfile.db1"/>
<isset property="gemfile.db2"/>
</and>
</not>
</condition>
</fail>
</target>
<target name="clean" description="Trash all build outputs">
<delete dir="${build}" />
<delete dir="${build.test}" />
<delete dir="${lib}" />
</target>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${build.classes}"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${src.java}" destdir="${build.classes}" debug="true" classpathref="compile.classpath" />
</target>
<target name="init-test" depends="init">
<mkdir dir="${build.test}" />
</target>
<target name="compile-test" depends="dist,init-test">
<javac debug="true" srcdir="${test.src.dir}" destdir="${build.test}" classpathref="test.classpath" />
</target>
<target name="configure-ruby-database-yml">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c 'test/update_database_yml.sh test/test_project/database_1/config/database.yml ${db.user} ${db.pass}'" />
</exec>
</target>
<target name="setup-db" depends="init-test,configure-ruby-database-yml">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c 'test/create_databases.sh ${db.user} ${db.pass}'" />
</exec>
<exec executable="/bin/sh" failonerror="true">
<arg line="test/migrate_project.sh test/test_project/database_1" />
</exec>
</target>
<target name="generate" description="generate test project java code">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c bundle install" />
</exec>
<exec executable="/bin/sh" failonerror="true">
<arg line="-c test/regen_code.sh" />
</exec>
</target>
<target name="generate-mysql-flex">
<delete file="src/java/com/rapleaf/jack/util/MysqlFlex.java"/>
<exec executable="/bin/sh" failonerror="true">
<arg line="-c 'java -cp jflex/JFlex.jar JFlex.Main -d src/java/com/rapleaf/jack/util src/jflex/mysql.flex'" />
</exec>
</target>
<target name="rspec">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c bundle exec rspec test/rb" />
</exec>
</target>
<target name="configure-java-database-yml">
<exec executable="/bin/sh" failonerror="true">
<arg line="-c 'test/update_database_yml.sh config/database.yml ${db.user} ${db.pass}'" />
</exec>
</target>
<target name="junit-test" depends="compile-test,configure-java-database-yml" description="Run the unit test suite">
<mkdir dir="${test.log.dir}"/>
<junit
printsummary="yes" showoutput="${test.output}"
haltonfailure="no" fork="once" maxmemory="512m"
errorProperty="tests.failed" failureProperty="tests.failed"
timeout="${test.timeout}"
>
<sysproperty key="build.test" value="${build.test}"/>
<sysproperty key="test.port" value="${test.port}" />
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.log.dir}" unless="testcase">
<fileset dir="${test.src.dir}" includes="**/Test*.java" />
</batchtest>
<batchtest todir="${test.log.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<target name="debug-test" if="testcase" description="Run a single unit test specified via '-Dtestcase [testcase]', pausing for an external debugger to connect">
<fileset id="selected.test.case" dir="${test.src.dir}" includes="**/${testcase}.java" />
<pathconvert refid="selected.test.case" property="testcase.exists" setonempty="false" />
<fail unless="testcase.exists">Specified testcase was not found!</fail>
<property name="debug.port" value="3408"/>
<junit
printsummary="yes" showoutput="${test.output}"
haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m"
errorProperty="tests.failed" failureProperty="tests.failed"
timeout="${test.timeout}"
>
<sysproperty key="build.test" value="${build.test}"/>
<!-- <jvmarg value="-Djava.library.path=${env.HADOOP_HOME}/lib/native/${build.platform}" /> -->
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.log.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
</batchtest>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,address=${debug.port},suspend=y"/>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<target name="test" depends="ensure-dbms-selected,setup-db,generate,rspec,junit-test" description="Run the entire test suite" />
<!-- TODO: need to build several jars here -->
<target name="dist" depends="resolve, compile" description="Build a distributable jar">
<exec executable="git" outputproperty="git.revision">
<arg value="rev-parse" />
<arg value="HEAD" />
</exec>
<jar jarfile="${jar.file}">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Implementation-Title" value="jack" />
<attribute name="Implementation-Vendor-Id" value="com.liveramp" />
<attribute name="Implementation-Build" value="${git.revision}" />
</manifest>
<fileset dir="${build.classes}">
<exclude name="**/test_project/**/*.class"/>
<include name="**/*.class" />
</fileset>
<fileset dir="${src.java}">
<include name="**/*.java" />
<exclude name="**/test_project/**/*.java"/>
</fileset>
<fileset dir="${src}">
<include name="**/*.rb" />
</fileset>
<fileset dir="${src}">
<include name="**/*.erb" />
</fileset>
<fileset dir=".">
<include name="Gemfile" />
</fileset>
</jar>
</target>
<target name="javadoc" depends="clean-javadoc" description="Generate Javadoc">
<mkdir dir="${doc}"/>
<javadoc sourcepath="${src.java}" destdir="${doc}"/>
</target>
<target name="clean-javadoc" description="Clean Javadoc">
<delete includeemptydirs="true" dir="${doc}"/>
</target>
<target name="install" depends="dist" description="Install">
<artifact:pom id="mypom" file="pom.xml" />
<artifact:install file="build/jack-1.0-SNAPSHOT.jar">
<pom refid="mypom"/>
</artifact:install>
</target>
<target name="deploy" depends="dist" description="Deploy">
<artifact:pom id="mypom" file="pom.xml" />
<artifact:deploy file="build/jack-1.0-SNAPSHOT.jar">
<pom refid="mypom"/>
</artifact:deploy>
</target>
</project>