|
1 | 1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
2 | | -<project name="strongback" default="dist"> |
| 2 | +<project name="strongback" default="dist" xmlns:antcontrib="antlib:net.sf.antcontrib"> |
| 3 | + <!-- Add Ant-Contrib --> |
| 4 | + <taskdef uri="antlib:net.sf.antcontrib" |
| 5 | + resource="net/sf/antcontrib/antlib.xml" |
| 6 | + classpath="libs/build/ant-contrib-1.0b3.jar"/> |
| 7 | + |
3 | 8 | <import file="dependencies.xml"/> |
4 | 9 | <tstamp> |
5 | 10 | <format property="current.year" pattern="yyyy" locale="en"/> |
6 | 11 | <format property="current.date" pattern="yyyy-MM-dd" locale="en"/> |
7 | 12 | </tstamp> |
8 | 13 | <property file="build.properties"/> |
| 14 | + <property name="wpilib.dir" value="libs/wpilib"/> |
9 | 15 | <property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/> |
| 16 | + <property file="${wpilib.dir}/wpilib.properties"/> |
10 | 17 | <property name="build.dir" value="build"/> |
11 | 18 |
|
12 | 19 | <target name="help"> |
|
16 | 23 | <echo> compile Compiles the source code in all projects</echo> |
17 | 24 | <echo> test Compiles and runs the tests in all projects</echo> |
18 | 25 | <echo> jar Compiles, runs the tests, and builds JAR files for all projects</echo> |
19 | | - <echo> dist Creates the distribution archive</echo> |
| 26 | + <echo> javadoc Builds the JavaDoc</echo> |
| 27 | + <echo> dist Creates the distribution ZIP and TAR archives in the `build` directory</echo> |
20 | 28 | <echo></echo> |
21 | 29 | <echo>Some of these targets depend on other targets. For example, running 'ant test' will</echo> |
22 | 30 | <echo>automatically include the 'compile' target, so it is equivalent to running 'ant compile test'.</echo> |
23 | 31 | <echo>Likewise, 'jar' automatically runs 'test', and 'dist' automatically runs 'clean' and 'jar'.</echo> |
24 | 32 | <echo></echo> |
| 33 | + <echo>There are a few other targets that are automatically run when the above targets are used,</echo> |
| 34 | + <echo>but which you may want to run manually:</echo> |
| 35 | + <echo></echo> |
| 36 | + <echo> dep Install the dependencies required to compile, run tests, and create the distribution.</echo> |
| 37 | + <echo> remove-dep Remove the dependencies installed by `dep`</echo> |
| 38 | + <echo></echo> |
25 | 39 | </target> |
26 | 40 |
|
27 | 41 | <target name="clean" description="Deletes build files"> |
|
31 | 45 | </antcall> |
32 | 46 | </target> |
33 | 47 |
|
34 | | - <target name="compile" description="Compiles source code"> |
| 48 | + <target name="compile" depends="dep" description="Compiles source code"> |
35 | 49 | <antcall target="strongback.all"> |
36 | 50 | <param name="dependency.target" value="compile"/> |
37 | 51 | </antcall> |
38 | 52 | </target> |
39 | 53 |
|
40 | | - <target name="test" description="Run the tests"> |
| 54 | + <target name="test" depends="dep" description="Run the tests"> |
41 | 55 | <antcall target="strongback.all"> |
42 | 56 | <param name="dependency.target" value="test"/> |
43 | 57 | </antcall> |
44 | 58 | </target> |
45 | 59 |
|
46 | | - <target name="jar" description="Creates the JARs"> |
| 60 | + <target name="jar" depends="dep" description="Creates the JARs"> |
47 | 61 | <antcall target="strongback.all"> |
48 | 62 | <param name="dependency.target" value="jar"/> |
49 | 63 | </antcall> |
|
85 | 99 |
|
86 | 100 | <target name="dist" depends="clean, jar, javadoc" description="Creates the distribution"> |
87 | 101 | <echo>Building Strongback distribution version ${strongback.version}</echo> |
| 102 | + <echo>for the WPILib version ${wpilib.version} installed at ${wpilib.dir}</echo> |
88 | 103 | <mkdir dir="build"/> |
89 | 104 |
|
90 | 105 | <!-- Update the strongback.properties file --> |
|
120 | 135 | <delete file="${build.dir}/strongback-${strongback.version}.tar" /> |
121 | 136 |
|
122 | 137 | </target> |
| 138 | + |
| 139 | + <!-- Remove and clean dependencies --> |
| 140 | + <target name="remove-dep" depends="clean-downloads" description="Removes the locally-installed dependencies"> |
| 141 | + <!-- !!!! Always remove the *local* installation; never the one in ${wpilib.dir} !!!! --> |
| 142 | + <delete dir="libs/wpilib" /> |
| 143 | + </target> |
| 144 | + |
| 145 | + <!-- Remove and clean dependencies --> |
| 146 | + <target name="clean-downloads" description="Deletes the temporary downloads folder"> |
| 147 | + <delete dir="downloads" /> |
| 148 | + </target> |
| 149 | + |
| 150 | + <!-- Install Dependencies --> |
| 151 | + <target name="dep" depends="download-wpilib,clean-downloads" description="Downloads and installs the dependencies required for the build"> |
| 152 | + </target> |
| 153 | + |
| 154 | + <!-- Check if the WPI directory exists --> |
| 155 | + <target name="check-for-wpilib"> |
| 156 | + <condition property="wpilib-missing"> |
| 157 | + <not> |
| 158 | + <available file="${wpilib.dir}" type="dir"/> |
| 159 | + </not> |
| 160 | + </condition> |
| 161 | + </target> |
| 162 | + |
| 163 | + <!-- Install the WPI directory --> |
| 164 | + <target name="download-wpilib" depends="check-for-wpilib" if="wpilib-missing" > |
| 165 | + <echo>Downloading the WPILib library and installing into '${wpilib.dir}'.</echo> |
| 166 | + <mkdir dir="downloads"/> |
| 167 | + <!-- Download the 'site.xml' file that contains the URL to the feature we want, and get that URL --> |
| 168 | + <get src="${wpilib.updatesite.url}/site.xml" dest="downloads/site.xml"/> |
| 169 | + <xmlproperty file="downloads/site.xml" collapseAttributes="true" semanticAttributes="true" keepRoot="true"/> |
| 170 | + <antcontrib:for list="${site.feature.url}" param="url"> |
| 171 | + <sequential> |
| 172 | + <antcontrib:if> |
| 173 | + <contains string="@{url}" substring="java.feature"/> |
| 174 | + <then> |
| 175 | + <property name="javaFeatureUrl" value="@{url}"/> |
| 176 | + </then> |
| 177 | + </antcontrib:if> |
| 178 | + </sequential> |
| 179 | + </antcontrib:for> |
| 180 | + <antcontrib:propertyregex property="wpilib.version" input="${javaFeatureUrl}" regexp="_([\d.]*).jar" select="\1" casesensitive="false" /> |
| 181 | + <!-- The feature URL can be converted to the plugin URL --> |
| 182 | + <loadresource property="javaPluginUrl"> |
| 183 | + <propertyresource name="javaFeatureUrl"/> |
| 184 | + <filterchain> |
| 185 | + <tokenfilter> |
| 186 | + <filetokenizer/> |
| 187 | + <replacestring from="features" to="plugins"/> |
| 188 | + </tokenfilter> |
| 189 | + <tokenfilter> |
| 190 | + <filetokenizer/> |
| 191 | + <replacestring from="java.feature" to="java"/> |
| 192 | + </tokenfilter> |
| 193 | + </filterchain> |
| 194 | + </loadresource> |
| 195 | + <!-- Get the plugin JAR file, and extract it's 'java.zip' file --> |
| 196 | + <get src="${wpilib.updatesite.url}/${javaPluginUrl}" dest="downloads/wpi-java-plugin.jar"/> |
| 197 | + <unzip src="downloads/wpi-java-plugin.jar" dest="downloads"> |
| 198 | + <patternset> |
| 199 | + <include name="**/java.zip"/> |
| 200 | + </patternset> |
| 201 | + </unzip> |
| 202 | + <!-- Extract the 'java.zip' file into a new `wpilib` directory --> |
| 203 | + <mkdir dir="${wpilib.dir}/java/current"/> |
| 204 | + <unzip src="downloads/resources/java.zip" dest="${wpilib.dir}/java/current"> |
| 205 | + <patternset> |
| 206 | + <include name="**/*"/> |
| 207 | + </patternset> |
| 208 | + </unzip> |
| 209 | + <!-- Write out a property file in the directory --> |
| 210 | + <propertyfile file="${wpilib.dir}/wpilib.properties" comment="Downloaded and installed by Strongback build system"> |
| 211 | + <entry key="version" value="current"/> |
| 212 | + <entry key="wpilib.version" value="${wpilib.version}"/> |
| 213 | + </propertyfile> |
| 214 | + </target> |
| 215 | + |
123 | 216 | </project> |
0 commit comments