forked from kbase/kb_sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
283 lines (243 loc) · 11.4 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
272
273
274
275
276
277
278
279
280
281
282
<project name="KBase Module Builder" default="compile_and_bin" basedir=".">
<description>
Java Build file for the KBase Module Builder
</description>
<!-- set global properties that need to be overwritten by the Makefile or ant invoker -->
<!-- property name="BIN_TARGET" location="../../bin" / -->
<!-- property name="BIN_LIB_TARGET" location="dist"/ -->
<property name="TESTCFG" location="test/test.cfg"/>
<!-- set global properties for this build -->
<property name="src" location="src/java"/>
<property name="dist" location="dist"/>
<property name="bin.local" location="bin"/>
<property name="classes" location="classes"/>
<property name="test.dir" location="temp_test_files"/>
<property name="test.script.dir" location="test_scripts"/>
<property name="test.config" value="${test.script.dir}/test.cfg"/>
<property name="test.script" value="test_module_builder.sh"/>
<property name="ee.dir" value="${test.script.dir}/ee_mock_service"/>
<property name="ee.start.script" value="start_service.sh"/>
<property name="ee.stop.script" value="stop_service.sh"/>
<!-- define the output jar and shell script filenames -->
<property name="kidl.jar.file" value="kbase-kidl-parser.jar"/>
<property name="module_builder.jar.file" value="kbase_module_builder2.jar"/>
<property name="module_builder.sh.file" value="kb-mobu"/>
<!-- If the BIN_LIB_TARGET is defined, then use the jars from the target destination
when including the classpath for the bin -->
<condition property="jardir" value="${BIN_LIB_TARGET}/jars">
<isset property="BIN_LIB_TARGET"/>
</condition>
<property environment="env"/>
<condition property="jardir" value="../jars/lib/jars/">
<or>
<equals arg1="${env.JENKINS_JARS_MODULE_PATH}" arg2=""/>
<not>
<isset property="env.JENKINS_JARS_MODULE_PATH"/>
</not>
</or>
</condition>
<!-- Properties in ant are immutable, so the following assignment will only take place if jardir was not set above. -->
<property name="jardir" location="${env.JENKINS_JARS_MODULE_PATH}/lib/jars"/>
<condition property="commonjar" value="kbase/common/kbase-common-0.0.12.jar">
<or>
<equals arg1="${env.JENKINS_JAVA_COMMON_JARFILE}" arg2=""/>
<not>
<isset property="env.JENKINS_JAVA_COMMON_JARFILE"/>
</not>
</or>
</condition>
<!-- Properties in ant are immutable, so the following assignment will only take place if jardir was not set above. -->
<property name="commonjar" value="${env.JENKINS_JAVA_COMMON_JARFILE}"/>
<target name="init">
<!-- Create the output directory structure-->
<mkdir dir="${classes}"/>
<mkdir dir="${dist}"/>
<mkdir dir="${bin.local}"/>
<mkdir dir="${test.dir}"/>
<mkdir dir="${ee.dir}"/>
</target>
<target name="compile" depends="init" description="compile the source">
<!-- Compile class files-->
<echo>Compiling with jar directory: ${jardir}</echo>
<javac destdir="${classes}" srcdir="${src}" includeantruntime="false" debug="true" classpathref="compile.classpath" />
<!-- Copy resource files-->
<copy todir="${classes}">
<fileset dir="${src}">
<patternset>
<include name="**/*.properties"/>
</patternset>
</fileset>
</copy>
<!-- Make main jar file-->
<jar destfile="${dist}/${module_builder.jar.file}" basedir="${classes}">
<manifest>
<attribute name="Main-Class" value="us.kbase.mobu.ModuleBuilder"/>
</manifest>
</jar>
<copy todir="${classes}">
<fileset dir="${src}">
<patternset>
<include name="us/kbase/kidl/**/*.java"/>
<include name="us/kbase/jkidl/**/*.java"/>
</patternset>
</fileset>
</copy>
<jar destfile="${dist}/${kidl.jar.file}">
<fileset dir="${classes}">
<include name="us/kbase/kidl/**"/>
<include name="us/kbase/jkidl/**"/>
</fileset>
</jar>
<!-- Remove uncompressed class files-->
<delete dir="${classes}"/>
</target>
<path id="compile.classpath">
<fileset dir="${jardir}">
<include name="kohsuke/args4j-2.0.21.jar"/>
<include name="codemodel/codemodel-2.4.1.jar"/>
<include name="apache_commons/commons-io-2.4.jar"/>
<include name="ini4j/ini4j-0.5.2.jar"/>
<include name="jackson/jackson-annotations-2.2.3.jar"/>
<include name="jackson/jackson-core-2.2.3.jar"/>
<include name="jackson/jackson-databind-2.2.3.jar"/>
<include name="jetty/jetty-all-7.0.0.jar"/>
<include name="jna/jna-3.4.0.jar"/>
<include name="google/jsonschema2pojo-core-0.3.6.jar"/>
<include name="google/guava-14.0.1.jar"/>
<include name="junit/junit-4.9.jar"/>
<include name="kbase/auth/kbase-auth-1380919426-d35c17d.jar"/>
<include name="servlet/servlet-api-2.5.jar"/>
<include name="syslog4j/syslog4j-0.9.46.jar"/>
<include name="apache_commons/commons-lang-2.4.jar"/>
<include name="apache_commons/velocity-1.7.jar"/>
<include name="apache_commons/commons-collections-3.2.1.jar"/>
<include name="jcommander/jcommander-1.48.jar"/>
<include name="snakeyaml/snakeyaml-1.11.jar"/>
<include name="${commonjar}"/>
</fileset>
<!--fileset dir=".">
<include name="kbase-common-temp.jar"/>
</fileset-->
</path>
<target name="copy_kidl_jar" if="EXT_KIDL_JAR">
<!-- copy the kidl jar to a versioned jar suitable for addition to the jars repo -->
<copy file="${dist}/${kidl.jar.file}" tofile="${dist}/${EXT_KIDL_JAR}"/>
<echo>Successfully created versioned library jar: ${EXT_KIDL_JAR}</echo>
</target>
<target name="sh_bin" description="create shell file wrappers">
<!-- Define absolute path to main jar file-->
<property name="jar.absolute.path" location="${dist}/${module_builder.jar.file}"/>
<!-- Define classpath string with : delimiter from list of lib-jar files-->
<pathconvert targetos="unix" property="lib.classpath" refid="compile.classpath"/>
<!-- Create main shell script-->
<echo file="${bin.local}/${module_builder.sh.file}">#!/bin/sh
export JAVA_HOME=${env.JAVA_HOME}
export PATH=$JAVA_HOME/bin:$PATH
$JAVA_HOME/bin/java -cp ${lib.classpath}:${jar.absolute.path} us.kbase.mobu.ModuleBuilder $@
</echo>
<chmod file="${bin.local}/${module_builder.sh.file}" perm="a+x"/>
<echo>Successfully built: ${bin.local}/${module_builder.sh.file}</echo>
<!-- Create start/stop scripts for the local mock Execution Engine-->
<echo file="${ee.dir}/${ee.start.script}">#!/bin/bash
export JAVA_HOME=${env.JAVA_HOME}
export PATH=$JAVA_HOME/bin:$PATH
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
PORT=8000
if [ -z $1 ]; then echo "port is not set, listening on $PORT"; else PORT=$1; fi
$JAVA_HOME/bin/java -cp ${lib.classpath}:${jar.absolute.path} us.kbase.kbasejobservice.KBaseJobServiceServer $PORT > $DIR/out_$1.txt 2> $DIR/err_$1.txt & pid=$!
echo $pid > $DIR/pid.txt
</echo>
<chmod file="${ee.dir}/${ee.start.script}" perm="a+x"/>
<echo>Successfully built: ${ee.dir}/${ee.start.script}</echo>
<echo file="${ee.dir}/${ee.stop.script}">#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
kill $(<"$DIR/pid.txt")
</echo>
<chmod file="${ee.dir}/${ee.stop.script}" perm="a+x"/>
<echo>Successfully built: ${ee.dir}/${ee.stop.script}</echo>
</target>
<target name="compile_and_bin" depends="compile, copy_kidl_jar, sh_bin" description="compile and create shell file in the local bin directory" >
</target>
<target name="copy_local_bin" description="copies the module_builder binary to the BIN_TARGET">
<fail message="file ${bin.local}/${module_builder.sh.file} is missing- did you forget to compile or run make first?">
<condition>
<not><available file="${bin.local}/${module_builder.sh.file}" /></not>
</condition>
</fail>
<fail message="BIN_TARGET ant property must be set to copy the local bin script">
<condition>
<not><isset property="BIN_TARGET" /></not>
</condition>
</fail>
<!-- Copy main shell script into the target bin folder-->
<copy todir="${BIN_TARGET}" flatten="true" verbose="true">
<fileset file="${bin.local}/${module_builder.sh.file}"/>
</copy>
<chmod file="${BIN_TARGET}/${module_builder.sh.file}" perm="a+x"/>
<echo>Successfully deployed dev bin to: ${BIN_TARGET}/${module_builder.sh.file}</echo>
</target>
<!-- deploy the module builder bin to the BIN_TARGET -->
<target name="deploy_bin" description="deploys the module builder shell script and libs if ">
<!-- fail if the jar file is missing -->
<fail message="file ${dist}/${module_builder.jar.file} is missing- did you forget to compile or run make first?">
<condition><not><available file="${dist}/${module_builder.jar.file}" /></not></condition>
</fail>
<!-- fail if the targets are not set -->
<fail message="BIN_TARGET and BIN_LIB_TARGET ant property must be set to deploy_bin">
<condition>
<or>
<not><isset property="BIN_TARGET" /></not>
<not><isset property="BIN_LIB_TARGET" /></not>
</or>
</condition>
</fail>
<!-- fail if the jars repo is not deployed to the BIN_TARGET location -->
<fail message="jars folder in ${BIN_LIB_TARGET} is missing- did you forget to deploy 'jars'?">
<condition><not><available file="${BIN_LIB_TARGET}/jars" /></not></condition>
</fail>
<!-- copy lib to target -->
<copy todir="${BIN_LIB_TARGET}" flatten="true">
<fileset file="${dist}/${module_builder.jar.file}"/>
</copy>
<echo>Successfully deployed lib to: ${BIN_LIB_TARGET}/${module_builder.jar.file}</echo>
<echo>Linking against jar directory: ${jardir}</echo>
<property name="jar.absolute.path" location="${BIN_LIB_TARGET}/${module_builder.jar.file}"/>
<!-- Define classpath string with : delimiter from list of lib-jar files-->
<pathconvert targetos="unix" property="lib.classpath" refid="compile.classpath"/>
<!-- Create main shell script-->
<echo file="${BIN_TARGET}/${module_builder.sh.file}">#!/bin/sh
export JAVA_HOME=${env.JAVA_HOME}
export PATH=$JAVA_HOME/bin:$PATH
$JAVA_HOME/bin/java -cp ${lib.classpath}:${jar.absolute.path} us.kbase.mobu.ModuleBuilder $@
</echo>
<chmod file="${BIN_TARGET}/${module_builder.sh.file}" perm="a+x"/>
</target>
<target name="preparejunitreportdir" if="env.JENKINS_REPORT_DIR">
<delete dir="${env.JENKINS_REPORT_DIR}"/>
<mkdir dir="${env.JENKINS_REPORT_DIR}"/>
</target>
<target name="test" depends="compile, preparejunitreportdir" description="create test script">
<!-- Define absolute path to main jar file-->
<junit printsummary="yes" haltonfailure="yes" fork="true">
<classpath>
<pathelement location="${dist}/${module_builder.jar.file}"/>
<path refid="compile.classpath"/>
</classpath>
<formatter type="plain" usefile="false" />
<formatter type="xml" usefile="true" if="env.JENKINS_REPORT_DIR"/>
<batchtest todir="${env.JENKINS_REPORT_DIR}">
<fileset dir="${src}">
<include name="**/test/**/**Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="clean" description="clean up" >
<!-- Clean up internal temporary files and folders-->
<delete dir="${classes}"/>
<delete dir="${dist}"/>
<delete dir="${test.dir}"/>
<delete dir="${bin.local}"/>
<delete dir="${ee.dir}"/>
</target>
</project>