Search code examples
javagradlebuilddependenciesimplementation

Could not resolve all files for configuration ':compileClasspath' (build.gradle)


I am currently working on a Java project (jdk-18.0.2.1; Gradle DSL: Groovy; Gradle Distribution: Wrapper; Gradle version 8.5) and want to use the following repositories and dependencies

repositories {
    mavenCentral()
    maven {
        url "https://repo.craftsblock.de/releases"
    }
}

dependencies {
    implementation 'net.minecraftforge:forgespi:' + spi_version
    implementation "de.craftsblock.craftscore:CraftsCore:3.7.49-SNAPSHOT"
}

in my build.gradle. When I build the project I get this error: Code Picture

I tried changing the used Java version in the project. But for 17/18/22 I get the same result.


Solution

  • You need to use at least Java 18 to use that dependency. When you tried to use different Java versions, then probably whatever you did failed to make Gradle execute with that new JVM.

    You could take further steps to confirm and correct the JVM Gradle is using. Or, perhaps more straightforwardly, you could also use a Java Toolchain which will establish the Java version your project uses to compile beyond any doubt.

    To use a toolchain, write the following in your build.gradle file:

    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(22) // Or 18, whichever you wish
        }
    }
    

    This forces your project to compile under Java 22, so it will either work or Gradle will tell you it can't find Java 22 and you can take it from there.