Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Strongback gradle project structure #108

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ build/
deploy/
target/
*.class
.gradle

# The 3rd party dependencies should never be committed
libs/wpilib
libs/ctre
libs/navx-mxp
downloads/

.DS_Store/
.DS_Store

4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ before_install:
- ant -version

install: ant deps
script: ant test
script:
- "ant test"
- "./gradlew build"
jdk:
- oraclejdk8
18 changes: 12 additions & 6 deletions build-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<property name="java.source.version" value="1.8"/>
<property name="java.target.version" value="1.8"/>
<property name="project.build.dir" value="build"/>
<property name="project.source.dir" value="src"/>
<property name="project.resources.dir" value="resources"/>
<property name="project.source.dir" value="src/main/java"/>
<property name="project.resources.dir" value="src/main/resources"/>
<property name="project.output.dir" value="${project.build.dir}/classes"/>
<property name="project.test.source.dir" value="test"/>
<property name="project.test.resources.dir" value="testresources"/>
<property name="project.test.source.dir" value="src/test/java"/>
<property name="project.test.resources.dir" value="src/test/resources"/>
<property name="project.test.output.dir" value="${project.build.dir}/test-classes"/>
<property name="project.test.report.dir" value="${project.build.dir}/test-reports"/>
<property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/>
Expand Down Expand Up @@ -54,14 +54,20 @@
<delete dir="${project.build.dir}" />
</target>

<target name="if-source">
<condition property="source-exists">
<available file="${project.source.dir}" type="dir"/>
</condition>
</target>

<!-- Check if there are any JUnit Tests -->
<target name="if-tests">
<condition property="tests-exists">
<available file="${project.test.source.dir}" type="dir"/>
</condition>
</target>

<target name="compile" description="Compile the code">
<target name="compile" depends="if-source" description="Compile the code" if="source-exists">
<echo>Compiling against WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
<mkdir dir="${project.output.dir}"/>
<javac srcdir="${project.source.dir}"
Expand Down Expand Up @@ -126,7 +132,7 @@
</target>

<!-- Override the several targets that will need to use the extra library JARs. -->
<target name="jar" depends="compile, test" description="Build and collect the JARs necessary for the robot">
<target name="jar" depends="compile, test" if="source-exists" description="Build and collect the JARs necessary for the robot">
<mkdir dir="${project.build.dir}" />
<jar destfile="${project.build.dir}/${project.jar.name}" basedir="${project.output.dir}"/>
<jar destfile="${project.build.dir}/${project.source.jar.name}" basedir="${project.source.dir}"/>
Expand Down
39 changes: 39 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
plugins {
id 'java'
}
ext {
baseDir = project.projectDir
}

subprojects {

apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

group = "org.strongback"
version = "2017.2.1-SNAPSHOT"

repositories {
maven {
url 'http://first.wpi.edu/FRC/roborio/maven/release'
}
}

dependencies {
testCompile('junit:junit:4.12')
testCompile('org.easytesting:fest-assert:1.4')
}

}

task wrapper(type: Wrapper) {
gradleVersion = '2.10'
}

ant.importBuild 'third-party.xml'
12 changes: 0 additions & 12 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,3 @@ strongback.version=2017.2.0
# replace the value with the URL of the WPILib Eclipse Update Site
#
wpilib.updatesite.url=http://first.wpi.edu/FRC/roborio/release/eclipse/

#
# Starting in 2017, WPILib will no longer have built-in support for the TalonSRX
# from Cross the Road Electronics (CTRE). Instead, the `CANTalon` class and associated
# functionality is available directly from CTRE as a separate JAR.
#
ctre.download.url=http://www.ctr-electronics.com/downloads/lib/CTRE_FRCLibs_NON-WINDOWS.zip

#
# The navX-MXP library is available in a ZIP file that has only the Java and C++ libraries.
#
navx.download.url=http://www.kauailabs.com/public_files/navx-mxp/navx-mxp-libs.zip
66 changes: 4 additions & 62 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<format property="current.date" pattern="yyyy-MM-dd" locale="en"/>
</tstamp>
<property file="build.properties"/>
<import file="third-party.xml" />

<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"/>

Expand Down Expand Up @@ -92,10 +92,10 @@
<pathelement path="${classpath}" />
</classpath>
<sourcefiles>
<fileset dir="strongback/src"/>
<fileset dir="strongback/src/main/java"/>
<!--fileset dir="strongback-testing/src"/-->
</sourcefiles>
<packageset dir="strongback/src" defaultexcludes="yes">
<packageset dir="strongback/src/main/java" defaultexcludes="yes">
<include name="org.strongback/**"/>
</packageset>

Expand Down Expand Up @@ -256,62 +256,4 @@
<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>
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sat Jan 23 19:15:02 EST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
160 changes: 160 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
#!/usr/bin/env bash

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
echo "$*"
}

die ( ) {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
Loading