Problem with Gradle build

Hey, we are experiencing some issues with building our project after installing CTRE Phoenix and navX libraries. Can someone help us? The build scan can be found here.

This is our build.gradle file:

plugins {
    id "java"
    id "edu.wpi.first.GradleRIO" version "2019.2.1"

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

def ROBOT_MAIN_CLASS = "frc.robot.Main"

// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project EmbeddedTools.
deploy {
    targets {
        roboRIO("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 = frc.getTeamOrDefault(5987)
    artifacts {
        frcJavaArtifact('frcJava') {
            targets << "roborio"
            // Debug can be overridden by command line, for use with VSCode
            debug = frc.getDebugOrDefault(false)
        // Built in artifact to deploy arbitrary files to the roboRIO.
        fileTreeArtifact('frcStaticFileDeploy') {
            // The directory below is the local directory to deploy
            files = fileTree(dir: 'src/main/deploy')
            // Deploy to RoboRIO target, into /home/lvuser/deploy
            targets << "roborio"
            directory = '/home/lvuser/deploy'

// Set this to true to enable desktop support.
def includeDesktopSupport = false

// Maven central needed for JUnit
repositories {

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
dependencies {
    compile wpi.deps.wpilib()
    compile navx()
    compile ctre()
    nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
    nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
    testCompile 'junit:junit:4.12'

// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)

Thank you!

You can no longer use ctre() or navx() for dependencies, you need to add each corresponding json preferences files in a folder in the root directory of your robot project make sure the folder is named vendordeps or the GradleRIO plugin will not pick it up.

your project folder should look something like this:


We added these JSON files through the “Manage Vendor Libraries”, I reinstalled this libraries. I removed these lines. And the project folder looks like what you’ve attached. I still get the same error, it looks like an error inside Gradle itself.
The error is:
* What went wrong: org.codehaus.groovy.runtime.DefaultGroovyMethods.each([Ljava/lang/Object;Lgroovy/lang/Closure;)[Ljava/lang/Object;

Install the Pheonix.json an navx_frc.json. They are libraries for your codes.

Did you update from an old gradlerio or alpha project. The version of Gradle needs to be updated as well for 2019, and we don’t have a direct upgrade path from old projects. Its recommended to create a new project and copy your source code in.

Otherwise, you’re going to need to follow gradles steps on how to update the wrapper version.

You need 5.0 for GradleRIO 2019. 4.9 (Which is what your scan shows you’re using) does not work.

From what I can see from the stacktrace its something going on when trying to parse through the json dependencies not sure what exactly is wrong:

java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.DefaultGroovyMethods.each([Ljava/lang/Object;Lgroovy/lang/Closure;)[Ljava/lang/Object;
at edu.wpi.first.gradlerio.wpi.dependencies.WPIVendorDepsExtension.load(WPIVendorDepsExtension.groovy:95)
at edu.wpi.first.gradlerio.wpi.dependencies.WPIVendorDepsExtension$_loadFrom_closure1.doCall(WPIVendorDepsExtension.groovy:68)

can we see your code? was the json prefs changed in anyway and your build.gradle after you changed it.

That was the problem! That is weird, becuase I downloaded FRC VS Code 2019, and so I expected the Gradle Wrapper version to be correct.
Anyway, I updated the Wrapper version to 5.1.1 with ./gradlew wrapper --gradle-version 5.1.1. This updated the gradle/wrapper/ file and then the build worked fine. Thank you!