0

I had a Maven project, which I then switched to Gradle. I am now attempting to compile the Gradle project, but it isn't compiling. For every method, Gradle says that it cannot find the symbol. In my Calendar.java class, here's what it says:

        Main instance = Main.getInstance();
                            ^
  symbol:   method getInstance()
  location: class Main

Maven used to compile the project fine, and the method getInstance() has always existed in the Main class. What can I do to fix this?

For reference, it's a multi-project build. Here's my build.gradle for the mother project:

plugins {
    id "java"
    id "com.github.johnrengelman.shadow" version "7.1.2"
    id "war"
}

group "net.pixlies"
version "1.0-SNAPSHOT"

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

subprojects {
    compileJava.options.encoding = "UTF-8"

    apply plugin: "java"
    apply plugin: "war"
    apply plugin: "com.github.johnrengelman.shadow"
}

repositories {
    mavenCentral()
    maven { url "https://repo.purpurmc.org/snapshots/" }
    maven { url "https://repo.extendedclip.com/content/repositories/placeholderapi/" }
    maven { url "https://repo.aikar.co/content/groups/aikar/" }
    maven { url "https://repo.dmulloy2.net/repository/public/" }
}

dependencies {
    implementation "org.mongodb:mongo-java-driver:3.12.11"
    implementation "commons-io:commons-io:2.11.0"
    implementation "co.aikar:acf-paper:0.5.1-SNAPSHOT"
    implementation "org.ocpsoft.prettytime:prettytime:5.0.3.Final"
    implementation "commons-lang:commons-lang:2.6"
}

This is the build.gradle of one of my modules, PixliesCore:

plugins {
    id 'net.pixlies.java-conventions'
}

dependencies {
    implementation 'com.github.stefvanschie.inventoryframework:IF:0.10.7'
    implementation 'org.projectlombok:lombok:1.18.24'
    implementation 'redis.clients:jedis:4.2.3'
    implementation 'joda-time:joda-time:2.11.1'
    compileOnly 'org.purpurmc.purpur:purpur-api:1.19-R0.1-SNAPSHOT'
    compileOnly 'com.comphenix.protocol:ProtocolLib:4.7.0'
    compileOnly 'me.clip:placeholderapi:2.11.2'
}

description = 'PixliesCore'

This is the console output for ./gradlew assemble

> Task :PixliesCore:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':PixliesCore:compileJava'.
> invalid source release: 16

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s
11 actionable tasks: 6 executed, 5 up-to-date

I notice that it says "invalid source release: 16," perhaps it is the problem. How would I fix this?

vPrototype
  • 109
  • 1
  • 8
  • Answering your question will be difficult unless you update your question to include more information. What are the contents of the other `build.gradle` files? What is the console output of `./gradlew assemble`? Where is `class Main` defined, and where is it used? – aSemy Dec 24 '22 at 13:33
  • Alright, I've updated my question. My Main class isn't really the problem because I am also getting errors for other methods in other classes. The one I showed was just an example. – vPrototype Dec 24 '22 at 13:42
  • The error `invalid source release: 16` leads to this question https://stackoverflow.com/q/46280859/4161471 - does that help? – aSemy Dec 24 '22 at 13:49
  • Check `getInstance()` is `public static Main getInstance() {...}` or `public Main getInstance() {...}` – life888888 Dec 24 '22 at 14:02
  • @life888888 It's static because it's a singleton. – vPrototype Dec 24 '22 at 14:23
  • @aSemy I set everything to Java 16, it still is not fixed. – vPrototype Dec 24 '22 at 14:23

0 Answers0