/
build.xml
218 lines (197 loc) · 10.7 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
<?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="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 dependencies required to compile, run tests, and create the distribution.</echo>
<echo> remove-deps Remove the dependencies installed by `dep`</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"/>
<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 © ${current.year} Strongback and individual contributors. All Rights Reserved.</i>]]></bottom>
<tag name="todo" scope="all" description="To do:"/>
<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"/>
</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 -->
<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}"/>
</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"/>
<tarfileset dir="libs" includes="*.jar" prefix="strongback/java/lib"/>
<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="strongback.properties" prefix="strongback"/>
<tarfileset dir="." includes="COPYRIGHT.txt" prefix="strongback"/>
<tarfileset dir="." includes="LICENSE.txt" prefix="strongback"/>
<tarfileset dir="." includes="README.md" prefix="strongback"/>
</tar>
<!-- Build the ZIP file (which may not maintain file permissions) -->
<zip destfile="${build.dir}/strongback-${strongback.version}.zip">
<tarfileset src="${build.dir}/strongback-${strongback.version}.tar"/>
</zip>
<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="libs/wpilib" />
</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,clean-downloads" description="Downloads and installs the dependencies required for the build">
</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>
<propertyregex property="wpilib.version" input="${javaFeatureUrl}" regexp="_([\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>
</project>