Skip to content

Commit 40540e6

Browse files
committed
Automatically install WPILib locally
This commit changes the build to use a WPILib distribution inside the `libs` folder. If the installation is not there, the Ant build will automatically download it via the standard WPILib Eclipse Update Site, and extract the Java-related artifacts into the `libs/wpilib` directory. The Eclipse projects were also changed to use this local installation. A local installation of WPILib will greatly improve consistency between different developers, and help us to maintain Strongback versions/branches that use different versions of WPILib.
1 parent 4fb71cc commit 40540e6

File tree

9 files changed

+144
-16
lines changed

9 files changed

+144
-16
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ deploy/
1212
target/
1313
*.class
1414

15+
# The wpilib directory should never be committed
16+
libs/wpilib
17+
downloads/
18+
1519
.DS_Store/

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@ Strongback is a new open source software library that makes your robot code ligh
1111
* **Logging** - Simple extendable framework to log messages at different levels.
1212
* **Uses WPILib** - Uses the WPILib classes underneath for safety and consistency.
1313

14+
# Using Strongback
15+
1416
Check out our new [Using Strongback](https://www.gitbook.com/book/strongback/using-strongback/) online book. It's chocked full of descriptions, details, and example code. The book's [Getting Started](https://strongback.gitbooks.io/using-strongback/content/getting_started.html) section shows you how to download, install, and use the [latest release](https://github.com/strongback/strongback-java/releases). Or, look at [this presentation](http://slides.com/strongback/using-strongback/#/) for an overview of the major features.
1517

1618
We're just getting started, so stay tuned. See [our wiki](https://github.com/strongback/strongback-java/wiki) for more details, including how you can help out!
19+
20+
# Building locally
21+
22+
If you want to build Strongback locally, you will need to have installed JDK 1.8, Eclipse Mars (version 4.5.0 or later), Ant 1.9.2 or later, and Git 2.2.1 or later. Then, use Git to clone this repository (or your GitHub fork). Before importing into Eclipse, build the code and run the unit tests using Ant:
23+
24+
$ ant test
25+
26+
This will download the appropriate version of WPILib and install it into the `libs` directory, and then compile all the code and run the unit tests. Once this works, you know your environment is set up correctly, and you can proceed to import the projects into your Eclipse workspace and view or make changes to the library and/or tests using Eclipse. At any time, you can run Ant to compile, test, or create distribution files.
27+
28+
If you have any problems getting this far, please check our [developers discussion forum](https://groups.google.com/forum/#!forum/strongback-dev) to see if others are having similar problems. If you see no relevant discussion, post a question with the details about your platform, the versions of the tools, what you are trying to do, and what result you are getting.
29+
30+
# Releasing
31+
32+
To release a new version of Strongback:
33+
34+
1. Change the `strongback.properties` file to reference the correct version number, and commit that to the repository.
35+
1. Build the distribution by running `ant clean dist` and verifying it completed correctly.
36+
1. Go to the [Strongback releases page](https://github.com/strongback/strongback-java/releases) and draft a new release, filling in the correct release candidate version number as the tag (e.g., `v1.0.0.RC1` for "release candidate 1") and giving an appropriate release title (e.g., `1.0.0 Release Candidate 1`) and description, and uploading the ZIP and compressed TAR file in the `build` directory. Then check "This is a pre-release" and press "Publish Release".
37+
1. Notify the developer forum so that other community members can test the release candidate by downloading and unpacking the pre-release distribution into their local home directory, using it in one or more robot codebases, and verifying the robots behave as expected. Each community member that tests it locally should respond to your forum post with their results.
38+
1. If the pre-release distribution has problems that need to be fixed, they should be reported, fixed, and merged into the correct branch, and then go to Step 3 using a new pre-release tag (e.g., `v1.0.0.RC2`) and title (e.g., `1.0.0 Release Candidate 1`).
39+
1. When enough community members have verified the pre-release distribution is acceptable, go to the [Strongback releases page](https://github.com/strongback/strongback-java/releases) and create a new release with the same tag as the pre-release, but with the appropriate release title (e.g., `1.0.0`) and description. Do not check "This is a pre-release" and press "Publish Release".

build-common.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="ISO-8859-1"?>
22
<project name="build-common" default="test">
33

4-
<property name="strongback.dir" value=".."/>
4+
<property name="strongback.dir" location=".."/>
55
<property file="${strongback.dir}/build.properties"/>
6+
<property name="wpilib.dir" value="${strongback.dir}/libs/wpilib"/>
67

7-
<property name="wpilib.dir" value="${user.home}/wpilib"/>
88
<property name="java.compile.arg" value=""/>
99
<property name="java.source.version" value="1.8"/>
1010
<property name="java.target.version" value="1.8"/>
@@ -57,6 +57,7 @@
5757
</target>
5858

5959
<target name="compile" description="Compile the code">
60+
<echo>Compiling against WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
6061
<mkdir dir="${project.output.dir}"/>
6162
<javac srcdir="${project.source.dir}"
6263
destdir="${project.output.dir}"
@@ -75,6 +76,7 @@
7576
</target>
7677

7778
<target name="compile-tests" depends="compile, if-tests" if="tests-exists" description="Compile the unit tests">
79+
<echo>Compiling against WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
7880
<mkdir dir="${project.test.output.dir}"/>
7981
<javac srcdir="${project.test.source.dir}"
8082
destdir="${project.test.output.dir}"
@@ -97,6 +99,7 @@
9799

98100
<!-- Run the JUnit Tests that are in the 'test' directory of this project -->
99101
<target name="test" depends="compile-tests, if-tests" if="tests-exists" description="Run the unit tests">
102+
<echo>Testing with WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
100103
<!-- Creates the directories used in the tests -->
101104
<mkdir dir="${project.test.output.dir}" />
102105
<mkdir dir="${project.test.report.dir}" />

build.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
strongback.version=1.0.3
2-
wpilib.dir=${user.home}/wpilib
2+
#
3+
# The build will download a specific version of the WPILib given by the following URL
4+
# and install it into the 'libs/wpilib' folder. To use a different version of WPILib,
5+
# replace the value with the URL of the WPILib Eclipse Update Site
6+
#
7+
wpilib.updatesite.url=http://first.wpi.edu/FRC/roborio/release/eclipse

build.xml

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<?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+
38
<import file="dependencies.xml"/>
49
<tstamp>
510
<format property="current.year" pattern="yyyy" locale="en"/>
611
<format property="current.date" pattern="yyyy-MM-dd" locale="en"/>
712
</tstamp>
813
<property file="build.properties"/>
14+
<property name="wpilib.dir" value="libs/wpilib"/>
915
<property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/>
16+
<property file="${wpilib.dir}/wpilib.properties"/>
1017
<property name="build.dir" value="build"/>
1118

1219
<target name="help">
@@ -16,12 +23,19 @@
1623
<echo> compile Compiles the source code in all projects</echo>
1724
<echo> test Compiles and runs the tests in all projects</echo>
1825
<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>
2028
<echo></echo>
2129
<echo>Some of these targets depend on other targets. For example, running 'ant test' will</echo>
2230
<echo>automatically include the 'compile' target, so it is equivalent to running 'ant compile test'.</echo>
2331
<echo>Likewise, 'jar' automatically runs 'test', and 'dist' automatically runs 'clean' and 'jar'.</echo>
2432
<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>
2539
</target>
2640

2741
<target name="clean" description="Deletes build files">
@@ -31,19 +45,19 @@
3145
</antcall>
3246
</target>
3347

34-
<target name="compile" description="Compiles source code">
48+
<target name="compile" depends="dep" description="Compiles source code">
3549
<antcall target="strongback.all">
3650
<param name="dependency.target" value="compile"/>
3751
</antcall>
3852
</target>
3953

40-
<target name="test" description="Run the tests">
54+
<target name="test" depends="dep" description="Run the tests">
4155
<antcall target="strongback.all">
4256
<param name="dependency.target" value="test"/>
4357
</antcall>
4458
</target>
4559

46-
<target name="jar" description="Creates the JARs">
60+
<target name="jar" depends="dep" description="Creates the JARs">
4761
<antcall target="strongback.all">
4862
<param name="dependency.target" value="jar"/>
4963
</antcall>
@@ -85,6 +99,7 @@
8599

86100
<target name="dist" depends="clean, jar, javadoc" description="Creates the distribution">
87101
<echo>Building Strongback distribution version ${strongback.version}</echo>
102+
<echo>for the WPILib version ${wpilib.version} installed at ${wpilib.dir}</echo>
88103
<mkdir dir="build"/>
89104

90105
<!-- Update the strongback.properties file -->
@@ -120,4 +135,82 @@
120135
<delete file="${build.dir}/strongback-${strongback.version}.tar" />
121136

122137
</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+
123216
</project>

strongback-examples/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry kind="var" path="wpilib" sourcepath="wpilib.sources"/>
5+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
6+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
67
<classpathentry kind="lib" path="/libs/test/fest-assert-1.4.jar" sourcepath="/libs/test/fest-assert-1.4-sources.jar"/>
78
<classpathentry kind="lib" path="/libs/test/fest-util-1.1.6.jar" sourcepath="/libs/test/fest-util-1.1.6-sources.jar"/>
89
<classpathentry kind="lib" path="/libs/test/junit-4.11.jar" sourcepath="/libs/test/junit-4.11-sources.jar"/>
910
<classpathentry kind="lib" path="/libs/test/hamcrest-core-1.3.jar" sourcepath="/libs/test/hamcrest-core-1.3-sources.jar"/>
10-
<classpathentry kind="var" path="networktables" sourcepath="networktables.sources"/>
1111
<classpathentry combineaccessrules="false" kind="src" path="/strongback"/>
1212
<classpathentry kind="output" path="build/classes"/>
1313
</classpath>

strongback-testing/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry kind="var" path="wpilib" sourcepath="wpilib.sources"/>
6-
<classpathentry kind="var" path="networktables" sourcepath="networktables.sources"/>
75
<classpathentry kind="lib" path="/libs/test/junit-4.11.jar" sourcepath="/libs/test/junit-4.11-sources.jar"/>
86
<classpathentry combineaccessrules="false" kind="src" path="/strongback"/>
97
<classpathentry kind="lib" path="/libs/test/metrics-core-3.1.0.jar" sourcepath="/libs/test/metrics-core-3.1.0-sources.jar"/>
8+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
9+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
1010
<classpathentry kind="output" path="build/classes"/>
1111
</classpath>

strongback-tests/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry kind="var" path="wpilib" sourcepath="wpilib.sources"/>
6-
<classpathentry kind="var" path="networktables" sourcepath="networktables.sources"/>
75
<classpathentry kind="lib" path="/libs/test/fest-assert-1.4.jar" sourcepath="/libs/test/fest-assert-1.4-sources.jar"/>
86
<classpathentry kind="lib" path="/libs/test/fest-util-1.1.6.jar" sourcepath="/libs/test/fest-util-1.1.6-sources.jar"/>
97
<classpathentry kind="lib" path="/libs/test/junit-4.11.jar" sourcepath="/libs/test/junit-4.11-sources.jar"/>
108
<classpathentry kind="lib" path="/libs/test/hamcrest-core-1.3.jar" sourcepath="/libs/test/hamcrest-core-1.3-sources.jar"/>
119
<classpathentry kind="lib" path="/libs/test/metrics-core-3.1.0.jar" sourcepath="/libs/test/metrics-core-3.1.0-sources.jar"/>
10+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
11+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
1212
<classpathentry combineaccessrules="false" kind="src" path="/strongback"/>
1313
<classpathentry combineaccessrules="false" kind="src" path="/strongback-testing"/>
1414
<classpathentry kind="output" path="build/classes"/>

strongback/.classpath

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry kind="var" path="wpilib" sourcepath="wpilib.sources"/>
6-
<classpathentry kind="var" path="networktables" sourcepath="networktables.sources"/>
5+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/WPILib.jar" sourcepath="/libs/wpilib/java/current/lib/WPILib-sources.jar"/>
6+
<classpathentry kind="lib" path="/libs/wpilib/java/current/lib/NetworkTables.jar" sourcepath="/libs/wpilib/java/current/lib/NetworkTables-sources.jar"/>
77
<classpathentry kind="output" path="build/classes"/>
88
</classpath>

0 commit comments

Comments
 (0)