-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.xml
317 lines (294 loc) · 16.2 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
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="strongback" default="dist">
<!-- Add Ant-Contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="libs/ant/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<import file="dependencies.xml"/>
<tstamp>
<format property="current.year" pattern="yyyy" locale="en"/>
<format property="current.date" pattern="yyyy-MM-dd" locale="en"/>
</tstamp>
<property file="build.properties"/>
<property name="wpilib.dir" value="libs/wpilib"/>
<property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/>
<property file="${wpilib.dir}/wpilib.properties"/>
<property name="ctre.dir" value="libs/ctre"/>
<property name="ctre.libs.dir" value="${ctre.dir}/java/lib"/>
<property name="navx.dir" value="libs/navx-mxp"/>
<property name="navx.libs.dir" value="${navx.dir}/roborio/java/lib"/>
<property name="build.dir" value="build"/>
<target name="help">
<echo>Building Strongback includes the following Ant targets:</echo>
<echo></echo>
<echo> clean Deletes all files and directories created during previous builds</echo>
<echo> compile Compiles the source code in all projects</echo>
<echo> test Compiles and runs the tests in all projects</echo>
<echo> jar Compiles, runs the tests, and builds JAR files for all projects</echo>
<echo> javadoc Builds the JavaDoc</echo>
<echo> dist Creates the distribution ZIP and TAR archives in the `build` directory</echo>
<echo></echo>
<echo>Some of these targets depend on other targets. For example, running 'ant test' will</echo>
<echo>automatically include the 'compile' target, so it is equivalent to running 'ant compile test'.</echo>
<echo>Likewise, 'jar' automatically runs 'test', and 'dist' automatically runs 'clean' and 'jar'.</echo>
<echo></echo>
<echo>There are a few other targets that are automatically run when the above targets are used,</echo>
<echo>but which you may want to run manually:</echo>
<echo></echo>
<echo> deps Install the WPILib and other dependencies required to compile, run tests, </echo>
<echo> and create the distribution. This does not affect files outside of this</echo>
<echo> `strongback-java` directory</echo>
<echo> remove-deps Remove the dependencies installed by `deps`</echo>
<echo></echo>
<echo>The following target is used during a Strongback release and is equivalent to removing</echo>
<echo>dependencies, cleaning, compiling, and creating the distribution:</echo>
<echo></echo>
<echo> release Equivalent to `ant remove-deps clean dist`</echo>
<echo></echo>
</target>
<target name="clean" description="Deletes build files">
<delete dir="${build.dir}" />
<antcall target="strongback.all">
<param name="dependency.target" value="clean"/>
</antcall>
</target>
<target name="compile" depends="deps" description="Compiles source code">
<antcall target="strongback.all">
<param name="dependency.target" value="compile"/>
</antcall>
</target>
<target name="test" depends="deps" description="Run the tests">
<antcall target="strongback.all">
<param name="dependency.target" value="test"/>
</antcall>
</target>
<target name="jar" depends="deps" description="Creates the JARs">
<antcall target="strongback.all">
<param name="dependency.target" value="jar"/>
</antcall>
</target>
<target name="javadoc">
<mkdir dir="build"/>
<javadoc destdir="build/javadoc"
author="false"
version="true"
use="true"
windowtitle="Strongback Java Library">
<classpath>
<fileset dir="libs" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${wpi.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${ctre.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${navx.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<pathelement path="${classpath}" />
</classpath>
<sourcefiles>
<fileset dir="strongback/src"/>
<!--fileset dir="strongback-testing/src"/-->
</sourcefiles>
<packageset dir="strongback/src" defaultexcludes="yes">
<include name="org.strongback/**"/>
</packageset>
<doctitle><![CDATA[<h1>Strongback Java Library</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright © 2015-${current.year} Strongback and individual contributors. All Rights Reserved.</i>]]></bottom>
<group title="Strongback" packages="org.strongback"/>
<group title="Components" packages="org.strongback.components*:org.strongback.hardware*"/>
<group title="Drives" packages="org.strongback.drive"/>
<group title="Commands" packages="org.strongback.command*"/>
<group title="" packages="org.strongback.util*:org.strongback.function*:org.strongback.annotation*"/>
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
<link offline="true" href="http://first.wpi.edu/FRC/roborio/release/docs/java/" packagelistLoc="${wpilib.dir}/java/current/javadoc"/>
<link offline="true" href="http://www.kauailabs.com/public_files/navx-mxp/apidocs/java/" packagelistLoc="${navx.dir}/java/docs"/>
</javadoc>
</target>
<target name="dist" depends="clean, jar, javadoc" description="Creates the distribution">
<echo>Building Strongback distribution version ${strongback.version}</echo>
<echo>for the WPILib version ${wpilib.version} installed at ${wpilib.dir}</echo>
<mkdir dir="build"/>
<!-- Update the strongback.properties file -->
<property file="${ctre.dir}/ctre.properties" prefix="ctre"/>
<property file="${navx.dir}/navx.properties" prefix="navx"/>
<copy file="strongback.properties" tofile="${build.dir}/strongback.properties"/>
<propertyfile file="${build.dir}/strongback.properties">
<entry key="strongback.version" value="${strongback.version}"/>
<entry key="build.date" value="${current.date}"/>
<entry key="wpilib.version" value="${wpilib.version}"/>
<entry key="ctre.version" value="${ctre.CTRE.FRC.Java}"/>
<entry key="navx.version" value="${navx.version}"/>
</propertyfile>
<propertyfile file="${build.dir}/ctre-lib-info.properties" comment="Generated by Strongback build system">
<entry key="version" value="${ctre.CTRE.FRC.Java}"/>
<entry key="name" value="TalonSRX Java Library"/>
<entry key="jarNames" value="TalonSRXLibJava.jar"/>
</propertyfile>
<propertyfile file="${build.dir}/navx-lib-info.properties" comment="Generated by Strongback build system">
<entry key="version" value="${navx.version}"/>
<entry key="name" value="navX-MXP Java Library"/>
<entry key="jarNames" value="navx_frc.jar"/>
</propertyfile>
<!-- Build the TAR file, which should maintain file permissions -->
<tar destfile="${build.dir}/strongback-${strongback.version}.tar">
<tarfileset dir="strongback-tools/scripts" prefix="strongback/java/bin" filemode="755"/>
<tarfileset dir="strongback/build" includes="*.jar" prefix="strongback/java/lib"/>
<!-- Copy all of the Strongback and 3rd party libraries needed on the robot into the `strongback/java/lib` directory -->
<tarfileset dir="libs" includes="*.jar" prefix="strongback/java/lib"/>
<tarfileset dir="libs/ctre/java/lib/" includes="*.*" prefix="strongback/java/lib"/>
<tarfileset dir="libs/navx-mxp/roborio/java/lib/" includes="*.jar" prefix="strongback/java/lib"/>
<!-- End of libraries needed on the robot -->
<tarfileset dir="strongback-testing/build" includes="*.jar" prefix="strongback/java/lib-tests"/>
<tarfileset dir="libs/test" includes="*.jar" prefix="strongback/java/lib-tests"/>
<tarfileset dir="strongback-tools/build" includes="*.jar" prefix="strongback/java/lib-tools"/>
<tarfileset dir="ant/strongback" includes="**" prefix="strongback/java/ant"/>
<tarfileset dir="templates" includes="**" prefix="strongback/java/templates"/>
<tarfileset dir="build/javadoc" includes="**" prefix="strongback/java/javadoc"/>
<tarfileset dir="build" includes="*.properties" prefix="strongback"/>
<tarfileset dir="." includes="COPYRIGHT.txt" prefix="strongback"/>
<tarfileset dir="." includes="LICENSE.txt" prefix="strongback"/>
<tarfileset dir="." includes="README.md" prefix="strongback"/>
<tarfileset dir="." includes="CONTRIBUTORS.txt" prefix="strongback"/>
</tar>
<!-- Build the ZIP file (which may not maintain file permissions) from the TAR file -->
<zip destfile="${build.dir}/strongback-${strongback.version}.zip">
<tarfileset src="${build.dir}/strongback-${strongback.version}.tar"/>
</zip>
<!-- Compress the TAR file -->
<gzip destfile="${build.dir}/strongback-${strongback.version}.tar.gz" src="${build.dir}/strongback-${strongback.version}.tar"/>
<delete file="${build.dir}/strongback-${strongback.version}.tar" />
</target>
<!-- Remove and clean dependencies -->
<target name="remove-deps" depends="clean-downloads" description="Removes the locally-installed dependencies">
<!-- !!!! Always remove the *local* installation; never the one in ${wpilib.dir} !!!! -->
<delete dir="${wpilib.dir}" />
<!-- TODO: Uncomment these when we automatically install them -->
<delete dir="${ctre.dir}" />
<delete dir="${navx.dir}" />
</target>
<!-- Remove and clean dependencies -->
<target name="clean-downloads" description="Deletes the temporary downloads folder">
<delete dir="downloads" />
</target>
<!-- Install Dependencies -->
<target name="deps" depends="download-wpilib,download-ctre,download-navx,clean-downloads" description="Downloads and installs the dependencies required for the build">
</target>
<!-- Release -->
<target name="release" depends="remove-deps,clean,dist" description="Removes and installs 3rd party libraries, compiles, and builds distribution.">
</target>
<!-- Check if the WPI directory exists -->
<target name="check-for-wpilib">
<condition property="wpilib-missing">
<not>
<available file="${wpilib.dir}" type="dir"/>
</not>
</condition>
</target>
<!-- Install the WPI directory -->
<target name="download-wpilib" depends="check-for-wpilib" if="wpilib-missing" >
<echo>Downloading the WPILib library and installing into '${wpilib.dir}'.</echo>
<mkdir dir="downloads"/>
<!-- Download the 'site.xml' file that contains the URL to the feature we want, and get that URL -->
<get src="${wpilib.updatesite.url}/site.xml" dest="downloads/site.xml"/>
<xmlproperty file="downloads/site.xml" collapseAttributes="true" semanticAttributes="true" keepRoot="true"/>
<for list="${site.feature.url}" param="url">
<sequential>
<if>
<contains string="@{url}" substring="java.feature"/>
<then>
<property name="javaFeatureUrl" value="@{url}"/>
</then>
</if>
</sequential>
</for>
<!-- Grab the WPILib version, of the form "2017.1.1.rc-2" -->
<propertyregex property="wpilib.version" input="${javaFeatureUrl}" regexp="_([\w\d.-]*).jar" select="\1" casesensitive="false" />
<!-- The feature URL can be converted to the plugin URL -->
<loadresource property="javaPluginUrl">
<propertyresource name="javaFeatureUrl"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="features" to="plugins"/>
</tokenfilter>
<tokenfilter>
<filetokenizer/>
<replacestring from="java.feature" to="java"/>
</tokenfilter>
</filterchain>
</loadresource>
<!-- Get the plugin JAR file, and extract it's 'java.zip' file -->
<get src="${wpilib.updatesite.url}/${javaPluginUrl}" dest="downloads/wpi-java-plugin.jar"/>
<unzip src="downloads/wpi-java-plugin.jar" dest="downloads">
<patternset>
<include name="**/java.zip"/>
</patternset>
</unzip>
<!-- Extract the 'java.zip' file into a new `wpilib` directory -->
<mkdir dir="${wpilib.dir}/java/current"/>
<unzip src="downloads/resources/java.zip" dest="${wpilib.dir}/java/current">
<patternset>
<include name="**/*"/>
</patternset>
</unzip>
<!-- Write out a property file in the directory -->
<propertyfile file="${wpilib.dir}/wpilib.properties" comment="Downloaded and installed by Strongback build system">
<entry key="version" value="current"/>
<entry key="wpilib.version" value="${wpilib.version}"/>
</propertyfile>
</target>
<!-- Download and install the CTRE library -->
<target name="check-for-ctre">
<condition property="ctre-missing">
<not>
<available file="${ctre.dir}" type="dir"/>
</not>
</condition>
</target>
<target name="download-ctre" depends="check-for-ctre" if="ctre-missing" >
<echo>Downloading the CTRE library and installing into '${ctre.dir}'.</echo>
<!-- Get and extra the ZIP file -->
<get src="${ctre.download.url}" dest="downloads/ctre.zip"/>
<!--copy file="/Users/rhauch/Downloads/CTRE_FRCLibs_NON-WINDOWS.zip" tofile="downloads/ctre.zip"/-->
<mkdir dir="${ctre.dir}"/>
<unzip src="downloads/ctre.zip" dest="${ctre.dir}">
</unzip>
<!-- Load the version info into a properties file -->
<loadfile property="ctre.version.properties" srcfile="${ctre.dir}/VERSION_NOTES">
<filterchain>
<!-- skip the first line -->
<headfilter lines="-1" skip="1"/>
<trim/>
<replacestring from=": " to="="/>
<replacestring from=" " to="."/>
</filterchain>
</loadfile>
<!-- Write out a property file in the CTRE directory -->
<echo file="${ctre.dir}/ctre.properties" append="false"># Downloaded and installed by Strongback build system${line.separator}</echo>
<echo file="${ctre.dir}/ctre.properties" append="true">${ctre.version.properties}</echo>
</target>
<!-- Download and extract the navX-MXP 3rd party library -->
<target name="check-for-navx">
<condition property="navx-missing">
<not>
<available file="${navx.dir}" type="dir"/>
</not>
</condition>
</target>
<target name="download-navx" depends="check-for-navx" if="navx-missing" >
<echo>Downloading the navX-MXP library and installing into '${navx.dir}'.</echo>
<get src="${navx.download.url}" dest="downloads/navx.zip"/>
<mkdir dir="${navx.dir}"/>
<unzip src="downloads/navx.zip" dest="${navx.dir}">
</unzip>
<!-- Load the version info into a property -->
<loadfile property="navx.version" srcFile="${navx.dir}/version.txt">
<filterchain>
<striplinebreaks/>
<trim/>
</filterchain>
</loadfile>
<!-- Write out a property file in the navX directory -->
<propertyfile file="${navx.dir}/navx.properties" comment="Downloaded and installed by Strongback build system">
<entry key="version" value="${navx.version}"/>
</propertyfile>
</target>
</project>