forked from LiveRamp/hank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
176 lines (149 loc) · 6.63 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
<project name="hank" default="dist" basedir=".">
<property name="version" value="0.1.0" />
<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="src.bash" location="${src}/bash" />
<property name="src.default_config" location="${src}/default_config" />
<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="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="jar.file" location="${build}/hank.jar" />
<property name="thrift.compiler" value="thrift" />
<fileset id="jars" dir="${lib}" includes="*.jar" />
<path id="compile.classpath">
<fileset id="jars" dir="${lib}" includes="*.jar" />
</path>
<target name="classpath">
<property name="cp" refid="test.run.classpath"/>
<pathelement location="${env.HADOOP_HOME}"/>
<pathelement location="${env.HADOOP_CONF_DIR}"/>
<echo message="Classpath: ${cp}"/>
</target>
<path id="test.classpath">
<path refid="compile.classpath" />
<pathelement location="${jar.file}" />
<pathelement location="${build.test}" />
</path>
<target name="clean" description="Trash all build outputs">
<delete dir="${build}" />
<delete dir="${build.test}" />
</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">
<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="test" depends="compile-test" 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>
<!-- TODO: need to build several jars here -->
<target name="dist" depends="compile" description="Build a distributable jar">
<!-- <mkdir dir="${build}/META-INF"/> -->
<!-- <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/> -->
<!-- <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/> -->
<jar jarfile="${jar.file}">
<fileset dir="${build.classes}">
<include name="**/*.class" />
<!-- <include name="META-INF/*.txt" /> -->
</fileset>
<fileset dir="${src.java}">
<include name="**/*.java" />
</fileset>
</jar>
</target>
<target name="gen-thrift" description="Generate the Thrift interfaces and structures" depends="init">
<delete dir="${src.java.generated}"/>
<exec executable="${thrift.compiler}" failonerror="true">
<arg line="-o ${build} --gen java:hashcode,nocamel,builder ${src}/hank.thrift" />
</exec>
<move todir="${src.java.generated}">
<fileset dir="${build}/gen-java/com/rapleaf/hank/generated" />
</move>
</target>
<target name="tar" description="Generate a Hank deploy tarball" depends="dist">
<delete dir="${build}/tar_temp" />
<mkdir dir="${build}/tar_temp/hank" />
<mkdir dir="${build}/tar_temp/hank/bin" />
<mkdir dir="${build}/tar_temp/hank/lib" />
<mkdir dir="${build}/tar_temp/hank/conf" />
<mkdir dir="${build}/tar_temp/hank/log" />
<!-- copy bash scripts to bin/ -->
<copy todir="${build}/tar_temp/hank/bin" >
<fileset dir="${src.bash}" includes="**/*" />
</copy>
<!-- copy jars to lib/ -->
<copy todir="${build}/tar_temp/hank/lib" >
<fileset dir="${lib}" includes="**/*" />
<fileset file="${jar.file}"/>
</copy>
<!-- copy default configs to conf/ -->
<copy todir="${build}/tar_temp/hank/conf" >
<fileset dir="${src.default_config}">
<include name="**/*.yaml"/>
<include name="**/*.log4j.properties"/>
</fileset>
</copy>
<!-- run tar command -->
<tar basedir="${build}/tar_temp" destfile="hank-deploy.tar.gz" compression="gzip"/>
<!-- delete tar_temp -->
<delete dir="${build}/tar_temp" />
</target>
</project>