Permalink
Fetching contributors…
Cannot retrieve contributors at this time
318 lines (294 sloc) 16.2 KB
<?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 &#169; 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>