Build.properties and build.xml

This page describes how the code is compiled and runs on the robot.

The standard for Java code compilation in FRC is to use Ant, which can automatically perform several subroutines, including compiling, copying code to the robot, and starting the program on the RoboRIO. In the case of our program, Ant first looks at the local build.xml file. This specifies the location of other files and should not be messed with (unless you have a really good reason).

''A note about file URLs: In order to allow for a universally applicable file heirarchy, WPI uses file URLs relative to certain ablsolute paths (such as ${user.home}). In order to access these absolute paths, variables are created and assigned values in .properties files. In order to access variables, the syntax '' ${variablename} So in the following, the section headers are merely the locations of the files.

${user.home}/wpilib/wpilib.properties
This is a simple file which we probably will not need to mess with unless we need to change our team number for some odd reason. Also, we could use multiple versions of WPILib if we had some good reason, but we probably will not (this would be used in the second build.properties section).

${project.home}/build.properties
Editing the first two non-commented lines would let us change the loction and name of our Robot.java class. We probably should not have to mess with this either.

${user.home}/wpilib/java/${version}/ant/build.properties
Note: The method described here no longer works as of 2017. The new method of adding libraries is by putting the jars in the (User)/wpilib/user/java/lib folder on your computer. The other information in the section most likely still applies, although I believe that the classpath variable in build.properties no longer is used in the build process.

This is where it gets interesting. Most of the properties have self explanatory names. Important ones are
 * The username and password fields, which we sometimes have to edit in order to allow write privaleges to the robot.
 * The libraries which we use. For example, on my computer, right after

networktables.sources=${wpilib.lib}/NetworkTables-sources.jar

I added the line

jsonsimple.jar=${user.home}/json_simple/lib/json_simple-1.1.jar

Which made a new variable for the location of the JSON_simple library. I then altered the line that read

classpath=${wpilib.jar}:${networktables.jar}

to say

classpath=${wpilib.jar}:${networktables.jar}:${jsonsimple.jar}

This incorporated the library into the so-called classpath so the compiler knew where to look for it.

${wpilib.ant.dir}/build.xml
Here is where the actual commands are run (by Ant). Following is an incomplete compilation of what they do.

echo
Just outputs text to the console.

javac and jar
javac is the standard Java compiler. jar can be thought of as comparable to .zip or .rar, but for Java classes. So for our project, javac compiles the .java files and stores them in ${project.home}/build. jar then bundles those, along with a bunch of .jar files (such as networktables.jar and rt.jar, which are found in the Referenced Libraries and JRE Standard Libraries), into a single file called FRCUserProgram.jar (found in ${project.home}/dist).

scp
scp copies a file (or file system) over a network connection. It requires network credentials (for security) and is the first encountered command to do so. Consequently, this step ocassionally fails due to incorrect login credentials.

sshexec
sshexec runs a command via a secure shell (ssh) connection. For example, this command is used to execute the user program on the robot after it has been pushed.