forked from twitter-archive/kestrel
/
compile.xml
183 lines (152 loc) · 6.1 KB
/
compile.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
<project xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="thrift.source.dir" value="${source.dir}/thrift" />
<property name="thrift.target.dir" value="${target.dir}/gen-java" />
<!-- generate thrift stubs if necessary -->
<macrodef name="generate-thrift">
<sequential>
<pathconvert property="thrift.gen.path">
<path location="${ivy.extra.thriftpackage}" />
<unpackagemapper from="${basedir}/*" to="${thrift.target.dir}/*" />
</pathconvert>
<mkdir dir="${thrift.target.dir}" />
<property name="thrift.bin" value="thrift" />
<apply executable="${thrift.bin}" dest="${thrift.gen.path}" failonerror="true"
skipemptyfilesets="true" verbose="true">
<arg value="--gen" />
<arg value="java" />
<arg value="--gen" />
<arg value="rb" />
<arg value="-o" />
<arg value="${target.dir}" />
<arg value="" />
<fileset dir="${thrift.source.dir}" includes="**/*.thrift" />
<globmapper from="*.thrift" to="*.java" />
</apply>
</sequential>
</macrodef>
<macrodef name="compile-generated-thrift">
<sequential>
<javac srcdir="${thrift.target.dir}" destdir="${target.dir}/classes" deprecation="on">
<classpath>
<path refid="deps.path" />
</classpath>
<include name="**/*.java" />
</javac>
</sequential>
</macrodef>
<target name="compile-thrift" if="build.thrift">
<generate-thrift />
<compile-generated-thrift />
</target>
<!-- if there's any jni, compile it -->
<target name="check-jni-source" if="build.jni">
<!-- tricksy. remove any target files if any non-target files are newer. -->
<dependset>
<srcfileset dir="src/main/jni" excludes="**/target/*.${os.jni.ext} **/target/*.jar" />
<targetfileset dir="src/main/jni" includes="**/target/*.${os.jni.ext} **/target/*.jar" />
</dependset>
<!-- and then only set build.jni.ok if those targets are "older" than build.xml (ie missing) -->
<uptodate property="build.jni.ok" targetfile="src/main/jni/build.xml">
<srcfiles dir="src/main/jni" includes="**/target/*.${os.jni.ext} **/target/*.jar" />
</uptodate>
</target>
<target name="compile-jni" depends="check-jni-source" if="build.jni.ok">
<ant dir="src/main/jni" target="compile" inheritAll="false" />
</target>
<target name="install-jni" depends="compile-jni" if="build.jni">
<copy todir="${dist.dir}" flatten="true">
<fileset dir="src/main/jni" includes="**/target/*.${os.jni.ext}" />
<fileset dir="src/main/jni" includes="**/target/*.jar" />
</copy>
</target>
<!-- compile old-skool java -->
<target name="compile-java" if="build.java">
<javac srcdir="${source.dir}/java" destdir="${target.dir}/classes" deprecation="on">
<classpath>
<path refid="deps.path" />
</classpath>
<include name="**/*.java" />
</javac>
</target>
<!-- compile scala -->
<target name="compile-scala" if="build.scala">
<scalac srcdir="${source.dir}/scala" destdir="${target.dir}/classes" force="changed" deprecation="on">
<classpath>
<path refid="deps.path" />
</classpath>
<include name="**/*.scala" />
</scalac>
</target>
<!-- create properties file with build info -->
<target name="find-git-revision" unless="no.git">
<!-- ask git for the current "head" commit-id, for memoizing inside the built jar -->
<exec outputproperty="revision" executable="git" failifexecutionfails="false">
<arg value="rev-parse" />
<arg value="HEAD" />
</exec>
<exec executable="git" failifexecutionfails="false">
<arg value="rev-parse" />
<arg value="HEAD" />
<redirector outputproperty="revision-short">
<outputfilterchain>
<tokenfilter>
<filetokenizer />
<replaceregex pattern="(.{8}).*" replace="\1"/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
</target>
<target name="write-build-info" depends="init, find-git-revision" if="ivy.extra.buildpackage">
<tstamp>
<format property="build.timestamp.time" pattern="yyyyMMdd-HHmmss" />
<format property="build.timestamp.date" pattern="yyyyMMdd" />
</tstamp>
<pathconvert property="build.properties.path">
<path location="${ivy.extra.buildpackage}" />
<unpackagemapper from="${basedir}/*" to="${target.dir}/classes/*" />
</pathconvert>
<propertyfile file="${build.properties.path}/build.properties">
<entry key="name" value="${ivy.module}" />
<entry key="version" value="${ivy.revision}" />
<entry key="build_name" value="${build.timestamp.time}" />
<entry key="build_revision" value="${revision}" />
</propertyfile>
</target>
<!-- copy resources needed by tests and jar -->
<target name="copy-resources">
<copy todir="${dist.dir}/libs" flatten="true">
<path refid="deps.path" />
</copy>
<copy todir="${target.dir}/test-classes/" failonerror="false">
<fileset dir="${test.source.dir}/resources" />
</copy>
<copy todir="${target.dir}/classes/" overwrite="true" failonerror="false">
<fileset dir="${source.dir}/resources" />
</copy>
</target>
<target name="copy-config" if="copy.config">
<copy todir="${dist.dir}/config">
<fileset dir="${basedir}/config" />
</copy>
</target>
<target name="copy-extra-config" if="config.extra">
<copy todir="${dist.dir}/config">
<fileset dir="${config.extra}" />
</copy>
</target>
<target name="copy-extra-libs" if="libs.extra">
<copy todir="${dist.dir}/libs">
<path refid="libs.extra" />
</copy>
</target>
<target name="copy-extra-dist" if="dist.extra">
<copy todir="${dist.dir}">
<path refid="dist.extra" />
</copy>
</target>
<target name="copy-extra" depends="copy-resources, copy-config, copy-extra-config, copy-extra-libs, copy-extra-dist" />
<target name="compile" depends="prepare, find-source, compile-thrift, check-jni-source, compile-jni,
install-jni, compile-java, compile-scala, write-build-info, copy-extra"
description="compile java and scala code" />
</project>