-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
executable file
·389 lines (344 loc) · 14.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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<?xml version="1.0" encoding="UTF-8"?>
<project name="CoderServer" default="buildRelease" >
<!-- ________________________ PROPERTIES AND SETTINGS ________________________ -->
<property name="version" value="0.1b" />
<property name="title" value="CoderServer" />
<property name="vendor" value="" />
<property name="build-type" value="black" />
<!--common properties-->
<property name="gitRoot" value="." />
<property name="srcDir" value="${gitRoot}/src" />
<property name="testDir" value="${gitRoot}/test" />
<property name="libDir" value="${gitRoot}/lib" />
<property name="buildRoot" value="${gitRoot}/build" />
<property name="releaseDir" value="${buildRoot}/release"/>
<property name="buildDir" value="${buildRoot}/production" />
<property name="pluginDir" value="${releaseDir}/plugins" />
<!--CodeServer properties-->
<property name="coderServerBuildDir" value="${buildDir}/coderServer/classes" />
<property name="coderServerJar" value="${releaseDir}/CoderServer.jar" />
<property name="coderServerTestDir" value="${buildDir}/coderServer/testLogs" />
<property name="coderServerPackage" value="com/coder/server" />
<!--Arduino plugin properties-->
<property name="arduinoBuildDir" value="${buildDir}/plugin/arduino/classes" />
<property name="arduinoJar" value="${releaseDir}/plugins/Arduino.jar" />
<property name="arduinoTestDir" value="${buildDir}/plugin/arduino/testLogs" />
<property name="arduinoPackage" value="com/coder/server/plugin/arduino" />
<!--Cpp plugin properties-->
<property name="cppBuildDir" value="${buildDir}/plugin/cpp/classes" />
<property name="cppJar" value="${releaseDir}/plugins/Cpp.jar" />
<property name="cppTestDir" value="${buildDir}/plugin/cpp/testLogs" />
<property name="cppPackage" value="com/coder/server/plugin/cpp" />
<!--Java properties-->
<property name="javaBuildDir" value="${buildDir}/plugin/java/classes" />
<property name="javaJar" value="${releaseDir}/plugins/Java.jar" />
<property name="javaTestDir" value="${buildDir}/plugin/java/testLogs" />
<property name="javaPackage" value="com/coder/server/plugin/java" />
<!--define standard arduments for javac-->
<presetdef name="javac">
<javac includeantruntime="false" />
</presetdef>
<!-- ________________________ CLASSPATHS ________________________ -->
<!--classpath included when building for release-->
<path id="classpath.release">
<!--include library license files-->
<fileset dir="${libDir}">
<include name="**jSerialComm*.txt"/>
<include name="**Zutil*.txt"/>
</fileset>
<!--include libraries used for building-->
<path refid="classpath.build"/>
</path>
<!--classpath included when building for test-->
<path id="classpath.test">
<pathelement location="${libDir}/junit-4.12.jar" />
<!--include libraries used for building-->
<path refid="classpath.build"/>
</path>
<!--classpath included when building-->
<path id="classpath.build">
<pathelement location="${libDir}/Zutil.jar" />
<pathelement location="${libDir}/jSerialComm-1.3.4.jar" />
</path>
<!-- ________________________ PUBLIC TARGETS ________________________ -->
<!--build release and run-->
<target name="run" depends="buildRelease">
<java fork="true" failonerror="true" dir="${releaseDir}" classname="com.coder.server.CoderServer">
<classpath>
<pathelement path="${releaseDir}/*"/> <!--wildcard may not be platform independent, ok?-->
<pathelement path="${releaseDir}/lib/*"/> <!--wildcard may not be platform independent, ok?-->
<pathelement path="${releaseDir}/plugins/*"/> <!--wildcard may not be platform independent, ok?-->
</classpath>
</java>
</target>
<!--build all target code and create .jar files -->
<target name="buildRelease" depends="buildAll, build-coder-server-jar, build-plugin-arduino-jar, build-plugin-cpp-jar, build-plugin-java-jar">
<!--create release dir-->
<mkdir dir="${releaseDir}" />
<!--copy licence file to release dir-->
<copy file="${gitRoot}/LICENSE.txt" todir="${releaseDir}" />
<!--copy readme file to release dir-->
<copy file="${gitRoot}/README.md" todir="${releaseDir}" />
<!--create release/lib dir-->
<mkdir dir="${releaseDir}/lib" />
<!--copy libs and related files to release/lib dir-->
<copy todir="${releaseDir}/lib" flatten="true">
<path refid="classpath.release" />
</copy>
<!--add startup script file to release dir-->
<copy file="${gitRoot}/start.sh" todir="${releaseDir}" />
<copy file="${gitRoot}/start.bat" todir="${releaseDir}" />
<!--make startup script file executable-->
<chmod file="${releaseDir}/start.sh" perm="u+x" />
<chmod file="${releaseDir}/start.bat" perm="u+x" />
</target>
<!--build all product code-->
<target name="buildAll" depends="clean, build-coder-server, build-plugin-arduino, build-plugin-cpp, build-plugin-java">
</target>
<!--build all product- and test code and run all tests -->
<target name="testAll" depends="clean, test-coder-server, test-plugin-arduino, test-plugin-cpp, test-plugin-java">
</target>
<!--clean all build paths-->
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${buildDir}" includes="**/*"/>
</delete>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${releaseDir}" includes="**/*"/>
</delete>
</target>
<target name="test-create-conf">
<!-- Users -->
<mkdir dir="${releaseDir}/user" />
<propertyfile file="${releaseDir}/user/ziver.properties">
<entry key="username" value="ziver" />
<entry key="passhash" value="b5f7e4383ad4f6840b96647275516d388526eca1044acd883a03a7c05878f06b" />
</propertyfile>
<propertyfile file="${releaseDir}/user/daniel.properties">
<entry key="username" value="daniel" />
<entry key="passhash" value="c61485b41343232a103438dcd85530557f9384fedad9b84a4622fc5a53ec3997" />
</propertyfile>
<!-- Projects -->
<mkdir dir="${releaseDir}/project/new_project/" />
<propertyfile file="${releaseDir}/project/new_project/.project">
<entry key="name" value="New Project" />
<entry key="description" value="My First Arduino project" />
<entry key="type" value="Arduino" />
</propertyfile>
</target>
<!-- ________________________ CODER SERVER ________________________ -->
<!--build product code and create jar file-->
<target name="build-coder-server-jar" depends="git.revision">
<mkdir dir="${releaseDir}" />
<jar destfile="${coderServerJar}" baseDir="${coderServerBuildDir}">
<manifest>
<attribute name="Main-class" value="com.coder.server.CoderServer" />
<attribute name="Implementation-Title" value="${title}" />
<attribute name="Implementation-Version" value="${version} (${repository.version}) (${build-type})" />
<attribute name="Implementation-Vendor" value="${vendor}" />
</manifest>
</jar>
</target>
<!--build product code-->
<target name="build-coder-server">
<delete dir="${coderServerBuildDir}" />
<mkdir dir="${coderServerBuildDir}" />
<javac srcdir="${srcDir}" destdir="${coderServerBuildDir}" fork="yes">
<include name="**/*.java" />
<exclude name="**/plugin/**" />
<classpath refid="classpath.build" />
</javac>
</target>
<!--build product- and test code-->
<target name="build-coder-server-test" depends="build-coder-server">
<javac srcdir="${testDir}" destdir="${coderServerBuildDir}" fork="yes">
<include name="**/${coderServerPackage}/**Test.java" />
<classpath refid="classpath.test" />
</javac>
</target>
<!--build product- and test code and run the tests-->
<target name="test-coder-server" depends="build-coder-server-test">
<delete dir="${coderServerTestDir}" />
<mkdir dir="${coderServerTestDir}" />
<junit printsummary="yes" showoutput="no" fork="yes" haltonfailure="yes" maxmemory="256m">
<classpath>
<path refid="classpath.test" />
<pathelement location="${coderServerBuildDir}" />
</classpath>
<formatter type="plain" />
<batchtest todir="${coderServerTestDir}">
<fileset dir="${coderServerBuildDir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
<!-- ________________________ ARDUINO PLUGIN ________________________ -->
<!--build product code and create jar file-->
<target name="build-plugin-arduino-jar" depends="git.revision">
<mkdir dir="${pluginDir}" />
<jar destfile="${arduinoJar}" baseDir="${arduinoBuildDir}">
<manifest>
<attribute name="Implementation-Title" value="${title}/ArduinoPlugin" />
<attribute name="Implementation-Version" value="${version} (${repository.version}) (${build-type})" />
<attribute name="Implementation-Vendor" value="${vendor}" />
</manifest>
</jar>
</target>
<!--build product code-->
<target name="build-plugin-arduino">
<delete dir="${arduinoBuildDir}" />
<mkdir dir="${arduinoBuildDir}" />
<javac srcdir="${srcDir}" destdir="${arduinoBuildDir}" fork="yes">
<include name="**/${arduinoPackage}/**.java" />
<classpath refid="classpath.build" />
</javac>
<copy todir="${arduinoBuildDir}">
<fileset dir="${srcDir}">
<include name="**/${arduinoPackage}/*.json"/>
</fileset>
</copy>
</target>
<!--build product- and test code-->
<target name="build-plugin-arduino-test" depends="build-plugin-arduino">
<javac srcdir="${testDir}" destdir="${arduinoBuildDir}" fork="yes">
<include name="**/${arduinoPackage}/**Test.java" />
<classpath refid="classpath.test" />
</javac>
</target>
<!--build product- and test code and run the tests-->
<target name="test-plugin-arduino" depends="build-plugin-arduino-test">
<delete dir="${arduinoTestDir}" />
<mkdir dir="${arduinoTestDir}" />
<junit printsummary="yes" showoutput="no" fork="yes" haltonfailure="yes" maxmemory="256m">
<classpath>
<path refid="classpath.test" />
<pathelement location="${arduinoBuildDir}" />
</classpath>
<formatter type="plain" />
<batchtest todir="${arduinoTestDir}">
<fileset dir="${arduinoBuildDir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
<!-- ________________________ CPP PLUGIN ________________________ -->
<!--build product code and create jar file-->
<target name="build-plugin-cpp-jar" depends="git.revision">
<mkdir dir="${pluginDir}" />
<jar destfile="${cppJar}" baseDir="${cppBuildDir}">
<manifest>
<attribute name="Implementation-Title" value="${title}/CppPlugin" />
<attribute name="Implementation-Version" value="${version} (${repository.version}) (${build-type})" />
<attribute name="Implementation-Vendor" value="${vendor}" />
</manifest>
</jar>
</target>
<!--build product code-->
<target name="build-plugin-cpp">
<delete dir="${cppBuildDir}" />
<mkdir dir="${cppBuildDir}" />
<javac srcdir="${srcDir}" destdir="${cppBuildDir}" fork="yes">
<include name="**/${cppPackage}/**.java" />
<classpath refid="classpath.build" />
</javac>
<copy todir="${cppBuildDir}">
<fileset dir="${srcDir}">
<include name="**/${cppPackage}/*.json"/>
</fileset>
</copy>
</target>
<!--build product- and test code-->
<target name="build-plugin-cpp-test" depends="build-plugin-cpp">
<javac srcdir="${testDir}" destdir="${cppBuildDir}" fork="yes">
<include name="**/${cppPackage}/**Test.java" />
<classpath refid="classpath.test" />
</javac>
</target>
<!--build product- and test code and run the tests-->
<target name="test-plugin-cpp" depends="build-plugin-cpp-test">
<delete dir="${cppTestDir}" />
<mkdir dir="${cppTestDir}" />
<junit printsummary="yes" showoutput="no" fork="yes" haltonfailure="yes" maxmemory="256m">
<classpath>
<path refid="classpath.test" />
<pathelement location="${cppBuildDir}" />
</classpath>
<formatter type="plain" />
<batchtest todir="${cppTestDir}">
<fileset dir="${cppBuildDir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
<!-- ________________________ JAVA PLUGIN ________________________ -->
<!--build product code and create jar file-->
<target name="build-plugin-java-jar" depends="git.revision">
<mkdir dir="${pluginDir}" />
<jar destfile="${javaJar}" baseDir="${javaBuildDir}">
<manifest>
<attribute name="Implementation-Title" value="${title}/JavaPlugin" />
<attribute name="Implementation-Version" value="${version} (${repository.version}) (${build-type})" />
<attribute name="Implementation-Vendor" value="${vendor}" />
</manifest>
</jar>
</target>
<!--build product code-->
<target name="build-plugin-java">
<delete dir="${javaBuildDir}" />
<mkdir dir="${javaBuildDir}" />
<javac srcdir="${testDir}" destdir="${javaBuildDir}" fork="yes">
<include name="**/${javaPackage}/**.java" />
<classpath refid="classpath.build" />
</javac>
<copy todir="${javaBuildDir}">
<fileset dir="${srcDir}">
<include name="**/${javaPackage}/*.json"/>
</fileset>
</copy>
</target>
<!--build product- and test code-->
<target name="build-plugin-java-test" depends="build-plugin-java">
<javac srcdir="${srcDir}" destdir="${javaBuildDir}" fork="yes">
<include name="**/${javaPackage}/**Test.java" />
<classpath refid="classpath.test" />
</javac>
</target>
<!--build product- and test code and run the tests-->
<target name="test-plugin-java" depends="build-plugin-java-test">
<delete dir="${javaTestDir}" />
<mkdir dir="${javaTestDir}" />
<junit printsummary="yes" showoutput="no" fork="yes" haltonfailure="yes" maxmemory="256m">
<classpath>
<path refid="classpath.test" />
<pathelement location="${javaBuildDir}" />
</classpath>
<formatter type="plain" />
<batchtest todir="${javaTestDir}">
<fileset dir="${javaBuildDir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</target>
<!-- ________________________ UTILITY ________________________ -->
<!--find the current GIT commit SHA-->
<available file="${gitRoot}/.git" type="dir" property="git.present" />
<target name="git.revision" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="describe" />
<arg value="--tags" />
<arg value="--always" />
<arg value="HEAD" />
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision" />
<length string="${git.revision}" trim="yes" length="0" when="greater" />
</and>
</condition>
<echo message="Current commit SHA is ${git.revision}" />
</target>
</project>