our 2018 code had some non-standard libraries; we made a /lib/ folder in the project, put the jars there, added the folder to the Eclipse build (so eclipse was happy), and listed the folder in build.properties (userLibs=lib/) so that Ant was happy when building.
How do we do this in the brave new world?
Assuming they’re publically available in repositories (and not custom-made ones that you build locally on the pc’s), here’s how we’re (attempting) to do it so far:
compile group: 'org.eclipse.jetty.websocket', name: 'websocket-client', version: '9.3.9.v20160517'
compile group: 'org.eclipse.jetty.websocket', name: 'websocket-servlet', version: '9.3.9.v20160517'
compile group: 'org.eclipse.jetty.websocket', name: 'websocket-api', version: '9.3.9.v20160517'
compile group: 'org.eclipse.jetty.websocket', name: 'websocket-common', version: '9.3.9.v20160517'
compile group: 'org.eclipse.jetty', name: 'jetty-io', version: '9.3.9.v20160517'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Define all the targets (for now just RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project EmbeddedTools.
///////////////////////////////////////////////////////////////////////////////////////////////////
deploy {
targets {
target("roborio", edu.wpi.first.gradlerio.frc.RoboRIO) {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = getTeamNumber()
If you do want a local file, you can do the following. The root is the root of your project.
compile files('lib/something_local.jar')
Put that inside your dependencies block.
that did it.
I see that ctre() wpilib() and navx() are all defined. Is there one for pathfinder?
I can place the pathfinder.jar we have been using in lib/ and call it out, but I don’t know how to handle the .so…
You should also be able to create your own repository by adding
repositories {
maven { url "file://" + projectDir + "/libs/java" }
}
And then using maven repository folder structure in the libs/java folder.
Example:
Have your jar in the following folder:
{project_directory}/libs/java/my/group/id/artifactid/version/artifactid-version.jar
and then add this in your dependencies section of your build.gradle
compile group: 'my.group.id', name: 'artifactid', version: 'version'
If you also have native dependencies, you can also add the following to your dependencies section as well to pick up those files.
nativeLib fileTree(dir: 'libs/native', include: '*.so')
EDIT:
For pathfinder there is a import function as well.
Just put the following in your dependencies section.
compile pathfinder()
Between this and the main thread, I’ll toss in a suggestion that a useful documentation section could be “Recipies” that shows short snippits of the recommended way of doing some of these advanced-but-somewhat-common actions.