Create a gist now

Instantly share code, notes, and snippets.

FRC 2017 WPILib lib-in-project
# This is our build.properties file. It's basically the same as 2016 except from line 9 on needs to be added.
# Project specific information
package=your.package.here.steamworks.robot
robot.class=${package}.Robot
simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world
# The full URL to the Eclipse Java Plugin to use to install WPILib
wpilib.pluginURL=http://first.wpi.edu/FRC/roborio/release/eclipse/plugins/edu.wpi.first.wpilib.plugins.java_2017.1.1.jar
# If set, and set to true or yes, will download and install the CTRE User Library
userLibInstallCtre=true
userLibInstallCtre.URL=http://www.ctr-electronics.com/downloads/lib/CTRE_FRCLibs_NON-WINDOWS.zip
userLibInstallCtre.docURL=http://www.ctr-electronics.com/downloads/api/CTRE-Toolsuite-API-Documentation.zip
<?xml version="1.0" encoding="UTF-8"?>
<project name="FRC Deployment" default="deploy">
<!--
The following properties can be defined to override system level
settings. These should not be touched unless you know what you're
doing. The primary use is to override the wpilib version when
working with older robots that can't compile with the latest
libraries.
-->
<!-- By default the system version of WPI is used -->
<property name="version" value="current"/>
<!-- By default the system team number is used -->
<property name="team-number" value="5881"/>
<!-- By default the target is set to 10.TE.AM.2 -->
<!-- <property name="target" value=""/> -->
<!-- Any other property in build.properties can also be overridden. -->
<property name="wpilib" value="wpilib"/>
<property name="userLibs.dir" value="${wpilib}/userLibs"/>
<property file="build.properties"/>
<property file="${wpilib}/ant/build.properties"/>
<property file="${wpilib}/ant/ni_image.properties"/>
<import file="${wpilib.ant.dir}/build.xml"/>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project name="WPILib Installation" default="install">
<!-- Load the build properties file. -->
<property file="build.properties"/>
<!-- Set these to the same values that are in build.xml, defaults should be fine. -->
<property name="wpilib" value="wpilib"/>
<property name="userLibs.dir" value="${wpilib}/userLibs"/>
<target name="clean" depends="wpilib.check" if="wpilib.exists">
<delete dir="${wpilib}"/>
<echo>WPILib Removed</echo>
</target>
<!-- Main target, chains the installation of WPILib, and user libraries as needed. -->
<target name="install" depends="doInstall, installCtre"/>
<!-- Install the WPILib library, but check to see if it's installed first, and abort if it is. -->
<target name="doInstall" depends="wpilib.check" unless="wpilib.exists">
<!-- Make the WPILib directory. -->
<mkdir dir="${wpilib}"/>
<!-- Get the WPILib Eclipse Java Plugin - the URL should be in build.properties. -->
<get src="${wpilib.pluginURL}" dest="${wpilib}/plugin.jar"/>
<!-- Unzip the Plugin, extracting only the java.zip file contained in it. This file has the
WPILib libraries and ANT scripts in it. Delete the plugin when done. -->
<unzip src="${wpilib}/plugin.jar" dest="${wpilib}">
<patternset>
<include name="resources/java.zip"/>
</patternset>
<mapper type="flatten"/>
</unzip>
<delete file="${wpilib}/plugin.jar" />
<!-- Unzip the java.zip file from the plugin to the WPILib directory, deleting when done. -->
<unzip src="${wpilib}/java.zip" dest="${wpilib}"/>
<delete file="${wpilib}/java.zip" />
<!-- Make the user library and docs directories. -->
<mkdir dir="${userLibs.dir}"/>
<mkdir dir="${userLibs.dir}/docs"/>
<echo>WPILib Installed</echo>
</target>
<!-- Target to install the CTRE Libraries for the CAN Talon, HERO board and other hardware.
Only executes if the userLibInstallCtre property is set to true or yes. Will overwrite
any existing versions. -->
<target name="installCtre" depends="wpilib.check" if="wpilib.installCtre">
<!-- Get the CTRE Library - the URL should be in build.properties. -->
<get src="${userLibInstallCtre.URL}" dest="${wpilib}/CTRE.zip"/>
<!-- Unzip the java portion of the library only, and delete when done. -->
<unzip src="${wpilib}/CTRE.zip" dest="${userLibs.dir}">
<patternset>
<include name="java/lib/*"/>
</patternset>
<mapper type="flatten"/>
</unzip>
<delete file="${wpilib}/CTRE.zip"/>
<!-- Get the CTRE Documentation - the URL should be in build.properties. -->
<get src="${userLibInstallCtre.docURL}" dest="${wpilib}/CTRE_docs.zip"/>
<!-- Create the CTRE documentation directory, and unzip the java docs into it, deleting when done. -->
<mkdir dir="${userLibs.dir}/docs/ctre"/>
<unzip src="${wpilib}/CTRE_docs.zip" dest="${userLibs.dir}/docs/ctre">
<patternset>
<include name="CTRE Toolsuite API Documentation/java/**"/>
</patternset>
<cutdirsmapper dirs="2"/>
</unzip>
<delete file="${wpilib}/CTRE_docs.zip"/>
<echo>CTRE Library and Documentation Installed</echo>
</target>
<target name="wpilib.check">
<condition property="wpilib.exists">
<available file="${wpilib}" type="dir"/>
</condition>
<condition property="wpilib.installCtre">
<istrue value="${userLibInstallCtre}"/>
</condition>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment