Code Monkey home page Code Monkey logo

gradlerio's Introduction

GradleRIO

GradleRIO is a powerful Gradle Plugin that allows teams competing in the FIRST robotics competition to produce and build their code.

GradleRIO works with Java and C++ (and others!), on Windows, Mac and Linux. GradleRIO automatically fetches WPILib, CTRE Toolsuite (Talon SRX) and NavX libraries, and you can even add your own libraries!

For 2019+, GradleRIO is the official build system for the FIRST Robotics Competition! The officially supported IDE is Visual Studio Code (VSCode), using the WPILib extension.

Other IDEs like IntelliJ IDEA, Eclipse, Visual Studio, and CLion are also supported, unofficially. You may also use this tool exclusively from the command line, allowing use of any IDE or text editor (like Sublime Text, Atom or Vim).

Commands

Windows Users: It is recommended to use Powershell instead of CMD.

  • ./gradlew build will build your Robot Code

  • ./gradlew deploy will build and deploy your code.

  • ./gradlew riolog will display the RoboRIO console output on your computer (run with -Pfakeds if you don't have a driverstation connected).

  • ./gradlew smartDashboard will launch Smart Dashboard

  • ./gradlew shuffleboard will launch Shuffleboard, the 2018 replacement for SmartDashboard.

  • ./gradlew installToolchain will install the C++ Toolchains for your system (required for C++).

At Competition? Connected to the Robot? Run with the --offline flag. e.g. ./gradlew build deploy --offline

IDE Commands

These IDEs are unofficially supported, so CSA support is not guaranteed. It is recommended to use VSCode, however these options are available if you wish.

  • ./gradlew idea will generate IDE files for IntelliJ IDEA (java)
  • ./gradlew eclipse will generate IDE files for Eclipse (java)
  • ./gradlew <component>VisualStudio will generate IDE files for the C/C++ component named <component> for Visual Studio (C++)
  • ./gradlew clion will generate IDE files for Clion (C++). Be warned that Clion support is hacky as Clion does not natively support Gradle.

Upgrading

To upgrade your version of GradleRIO, you must first upgrade gradle. Near the bottom of your build.gradle, change the wrapper version to the following, and then run ./gradlew wrapper:

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

Next, replace the version in the plugin line (only change the GradleRIO line):

plugins {
    // ... other plugins ...
    id "edu.wpi.first.GradleRIO" version "2019.0.0-alpha-3"
}

Implementation Details

NOTE: This section is for advanced users. View the examples for your language to get started.

Full Spec

deploy {
    targets {
        target('roborio', RoboRIO) {
            team = getTeamOrDefault(5333)
            // Other values can be edited through EmbeddedTools.
            // See https://github.com/JacisNonsense/EmbeddedTools#spec
        }
        // Other targets can be edited through EmbeddedTools.
        // See https://github.com/JacisNonsense/EmbeddedTools#spec
    }
    artifacts {
        // Setup a Java Artifact. Required for Java Users.
        artifact('myJava', FRCJavaArtifact) {
            targets << 'roborio'

            jvmArgs << '-Xmx=128m'      // Set more JVM Arguments. Optional.
            arguments << 'myCustomArgs' // The command-line arguments to launch your jar with. Optional.
            debug = getDebugOrDefault(false)                // Enable to enable java debugging on the RoboRIO. Default: false
            debugPort = 8348            // Set the debugging port. Default: 8348
            robotCommand = './myOtherProgram'       // Set the contents of robotCommand. Optional, usually created depending on above values.

            // Other values can be edited through EmbeddedTools.
            // See https://github.com/JacisNonsense/EmbeddedTools#spec
        }

        // Setup a C++ (Native) Artifact. Required for C++ (Native) Users
        artifact('myNative', FRCNativeArtifact) {
            targets << 'roborio'
            component = 'myFrcBinary'   // The name of the component you wish to build (required).

            arguments << 'myCustomArgs' // The command-line arguments to launch your jar with. Optional.
            debug = getDebugOrDefault(false)                // Enable to enable cpp debugging on the RoboRIO. Default: false
            debugPort = 8348            // Set the debugging port. Default: 8348
            robotCommand = './myOtherProgram'       // Set the contents of robotCommand. Optional, usually created depending on above values.

            // Other values can be edited through EmbeddedTools.
            // See https://github.com/JacisNonsense/EmbeddedTools#spec
        }
        // Other artifacts can be edited through EmbeddedTools.
        // See https://github.com/JacisNonsense/EmbeddedTools#spec
    }
}

// Set the versions of libraries to use. This is calculated for you based
// off known-stable versions for the current year, but you can modify
// them here if you so desire. This block is not required.
wpi {
    wpilibVersion = '...'
    ntcoreVersion = '...'
    opencvVersion = '...'
    cscoreVersion = '...'
    wpiutilVersion = '...'

    smartDashboardVersion = '...'
    shuffleboardVersion = '...'

    toolchainVersion = '...'
}

// Set the dependencies you want to use in your JAVA project.
// WPILib adds WPILibJ, NTCore, OpenCV, CSCore among others.
dependencies {
    compile wpilib()
}

// Java only. Setup your Jar File.
jar {
    // Compile a 'fat jar' (libraries included)
    from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    // Include your Manifest. Arguments are your Robot Main Class.
    manifest GradleRIOPlugin.javaManifest('test.myClass')
}

// Set up your Native (C++) projects. Not needed in Java.
model {
    components {
        myFrcBinary(NativeExecutableSpec) {
            targetPlatform 'roborio'
            sources.cpp {
                source {
                    srcDir 'src/main/cpp'
                }
            }
            // Add the libraries you wish to use in your NATIVE project.
            // WPILib adds WPILibJ, NTCore, OpenCV, CSCore among others.
            useLibrary(it, "wpilib")
        }
    }
}

gradlerio's People

Contributors

333fred avatar arvind-srinivasan avatar austinshalit avatar bob80333 avatar floogulinc avatar jacibrunning avatar jwhite66 avatar redrield avatar supercilex avatar thadhouse avatar williamkluge avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.