0

I've been working on a game with libGDX and was attempting to incorporate JUnit5 for the very first time only to find that the dependencies will not resolve no matter what I do. I have tried a large variety of solutions.

This is my build.gradle and I am getting the error: 'Unresolved dependency: org.junit.jupiter:junit-jupiter:5.9.3'

Any help would be appreciated!

buildscript {

    repositories {
        mavenLocal()
        mavenCentral()
        gradlePluginPortal()
        maven { url "https://repo.maven.apache.org/maven2/" }
        google()
    }
    dependencies {

    }
}

plugins {
    id 'java'
}  

allprojects {
    apply plugin: "eclipse"
    apply plugin: "checkstyle"

    def checkstyleVersion = "10.4"

    version = '1.0'
    ext {
        appName = "Piazza Panic"
        gdxVersion = '1.11.0'
        roboVMVersion = '2.3.16'
        box2DLightsVersion = '1.5'
        ashleyVersion = '1.7.4'
        aiVersion = '1.8.2'
        gdxControllersVersion = '2.2.1'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        google()
        gradlePluginPortal()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
        maven { url "https://jitpack.io" }
        maven {
            url 'https://repo.maven.apache.org/maven2/'
        }
    }

    configurations {
        checkstyleRules
    }

    dependencies {
        checkstyleRules(
            "com.puppycrawl.tools:checkstyle:${checkstyleVersion}") {
            transitive = false
        }
    }

    checkstyle {
        toolVersion "${checkstyleVersion}"
        config = resources.text.fromArchiveEntry(
            configurations.checkstyleRules, 'google_checks.xml')
    }
}

project(":desktop") {
    apply plugin: "java-library"


    dependencies {
        implementation project(":core")
        api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
        api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        implementation "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"

    }
    
    jar {
        manifest {
            attributes('Main-Class': 'cs.eng1.piazzapanic.DesktopLauncher')
        }
     }
}

project(":core") {
    apply plugin: "java-library"
     repositories {
        mavenLocal()
        mavenCentral()
        gradlePluginPortal()
        google()
    }

    dependencies {
        api "com.badlogicgames.gdx:gdx:$gdxVersion"
        implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        implementation files('lib/junit-jupiter-5.9.3.jar') 
        testImplementation('org.junit.jupiter:junit-jupiter:5.9.3')
        testImplementation 'com.badlogicgames.gdx:gdx-backend-headless:1.11.0'
    } 

    test {
        useJUnitPlatform()
    }
}

Nothing I have tried so far has helped.

What do I do next?

  • 1
    Can you show us the errors actually produced? What does the build tool say when you try to execute it? – markspace May 02 '23 at 17:22
  • @markspace the error in particular is `:core:test: Could not resolve org.junit.jupiter:junit-jupiter:5.8.1. Required by: project :core` But when running `./gradlew build`, it executes with no errors but does not resolve the dependency – Hilia Burke May 02 '23 at 17:25
  • Try this: https://stackoverflow.com/questions/44429751/how-to-use-junit-5-with-gradle – markspace May 02 '23 at 17:33
  • @markspace I ran through the solutions they have laid out in that post and was unable to get the dependency to resolve. I'm not really sure what the major difference is between my set-up and theirs. Thanks for the suggestion! – Hilia Burke May 02 '23 at 17:44
  • Your `mavenLocal` may be interfering, it's not recomended to have it, did you try commenting it out? – Andrés Alcarraz May 02 '23 at 19:45
  • @AndrésAlcarraz that's a very good idea and one i'll remember for future projects but unfortunately didn't prevent the error. – Hilia Burke May 02 '23 at 23:38
  • @HiliaBurke, ok, there is more noise to clear up, that I just noticed, today I was from my cellphone. The error you mentioned in an earlier comment, says that version `5.8.1` couldn't be resolved, however, you depend on `5.9.3`. The line `implementation files('lib/junit...`, it's also weird. I guess it's there from different tests, but in order to get help here, it is better to put a minimal reproducible error, so please remove anything that could depend on what you have on your system. Please add the error correctly formatted to the question and check it corresponds to the code you provide. – Andrés Alcarraz May 03 '23 at 02:14

0 Answers0