FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
221 stars 193 forks source link

fabric-loom 1.5+ java.lang.RuntimeException: Unexpected IllegalAccessException occurred (Gson 2.9.1) #1126

Closed zyxkad closed 1 month ago

zyxkad commented 1 month ago

When I using fabric-loom 1.5.+ or 1.6.+, somehow it will give me gson error. But when I using 1.4.+ or below, things are fine.

What I'm trying to execute is ./gradlew task

I never use any gson in the project.

Logs

FAILURE: Build failed with an exception.                                                                                                                     

* What went wrong:
A problem occurred configuring root project 'AdvancedPeripherals'.
> Failed to notify project evaluation listener.
   > Failed to setup Minecraft, java.lang.RuntimeException: Unexpected IllegalAccessException occurred (Gson 2.9.1). Certain ReflectionAccessFilter features require Java >= 9 to work correctly. If you are not using ReflectionAccessFilter, report this to the Gson maintainers.
   > Unexpected IllegalAccessException occurred (Gson 2.9.1). Certain ReflectionAccessFilter features require Java >= 9 to work correctly. If you are not using ReflectionAccessFilter, report this to the Gson maintainers.

gradle.debug.log

build.gradle ```gradle import net.darkhax.curseforgegradle.TaskPublishCurseForge import java.text.SimpleDateFormat plugins { id "maven-publish" id "fabric-loom" version "1.6.+" id "net.darkhax.curseforgegradle" version "1.1.16" id "org.jetbrains.changelog" version "1.2.1" id "com.modrinth.minotaur" version "2.+" id "org.jetbrains.kotlin.jvm" version "1.6.10" // id "net.neoforged.gradle" version "[6.0.18,6.2)" // id "org.spongepowered.mixin" version "0.7.+" id "com.github.breadmoirai.github-release" version "2.5.2" id "checkstyle" id "java" } java { toolchain { languageVersion = JavaLanguageVersion.of(java_version) } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this line, sources will not be generated. withSourcesJar() sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } wrapper { gradleVersion = "8.6" distributionType = Wrapper.DistributionType.ALL } def isSnapshotVersion = project.hasProperty("teamcityBuild") version = "${mod_version}" + (isSnapshotVersion ? "-SNAPSHOT" : "") group = "de.srendi.advancedperipherals" def static getenv(path = ".env") { def env = [:] def file = new File(path) if (file.exists()) { file.eachLine { line -> def (name, value) = line.tokenize("=") if (value != null) { env[name.trim()] = value.trim() } } } return env } def secretEnv = getenv() def curseforgeKey = secretEnv["CURSEFORGE_KEY"] ?: System.getenv("CURSEFORGE_KEY") ?: "" def modrinthKey = secretEnv["MODRINTH_KEY"] ?: System.getenv("MODRINTH_KEY") def repositoryName = secretEnv["PUBLIC_REP_NAME"] ?: System.getenv("PUBLIC_REP_NAME") def repositoryKey = secretEnv["PUBLIC_REP_KEY"] ?: System.getenv("PUBLIC_REP_KEY") def githubKey = secretEnv["GITHUB_KEY"] ?: System.getenv("GITHUB_KEY") // Include resources generated by data generators. sourceSets { main.resources { srcDir "src/generated/resources" } testMod {} } /* minecraft { mappings channel: "${mappings_channel}", version: "${mappings_version}" accessTransformer file("src/main/resources/META-INF/accesstransformer.cfg") accessTransformer file("src/testMod/resources/META-INF/accesstransformer.cfg") runs { client { workingDirectory project.file("run") property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" property "mixin.env.remapRefMap", "true" property "mixin.env.refMapRemappingFile", "${buildDir}/createSrgToMcp/output.srg" properties "forge.logging.console.level": "debug" mods { advancedperipherals { source sourceSets.main } } if (project.hasProperty("mc_uuid")) { args "--uuid", project.getProperty("mc_uuid") } if (project.hasProperty("mc_username")) { args "--username", project.getProperty("mc_username") } if (project.hasProperty("mc_accessToken")) { args "--accessToken", project.getProperty("mc_accessToken") } } server { workingDirectory project.file("server") property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" property "mixin.env.remapRefMap", "true" property "mixin.env.refMapRemappingFile", "${buildDir}/createSrgToMcp/output.srg" property "forge.logging.console.level", "info" mods { advancedperipherals { source sourceSets.main } } } data { workingDirectory project.file("run") property "forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP" property "mixin.env.remapRefMap", "true" property "mixin.env.refMapRemappingFile", "${buildDir}/createSrgToMcp/output.srg" property "forge.logging.console.level", "debug" args "--mod", "advancedperipherals", "--all", "--existing", file("src/main/resources").toString(), "--existing", file("src/generated/resources").toString(), "--output", file("src/generated/resources/") mods { advancedperipherals { source sourceSets.main } } } testClient { workingDirectory project.file("test-files/client") parent runs.client mods { aptest { source sourceSets.testMod } } lazyToken("minecraft_classpath") { (configurations.implementationExtra.copyRecursive().resolve()) .collect { it.absolutePath } .join(File.pathSeparator) } } testServer { workingDirectory project.file("test-files/server") parent runs.server mods { aptest { source sourceSets.testMod } } lazyToken("minecraft_classpath") { (configurations.implementationExtra.copyRecursive().resolve()) .collect { it.absolutePath } .join(File.pathSeparator) } } } } */ repositories { mavenCentral() maven { name = "Squiddev maven cct" url = "https://squiddev.cc/maven" content { includeGroup "org.squiddev" includeGroup "cc.tweaked" includeModule("org.squiddev", "Cobalt") } } maven { name = "Blamejared maven botania patchouli" url = "https://maven.blamejared.com" content { includeGroup "vazkii.botania" includeGroup "vazkii.patchouli" } } maven { url = "https://jitpack.io" content { includeGroup "com.github.emilyploszaj" } } maven { url = "https://maven.jamieswhiteshirt.com/libs-release" content { includeGroup "com.jamieswhiteshirt" } } maven { name = "Theillusivec4 maven curios" url = "https://maven.theillusivec4.top" content { includeGroup "top.theillusivec4.curios" } } maven { name = "TerraformersMC" url = "https://maven.terraformersmc.com" content { includeGroup "dev.emi" // trinkets } } maven { name = "Ladysnake Libs" url = "https://maven.ladysnake.org/releases" content { includeGroup "com.github.Chocohead" includeGroup "com.github.LlamaLad7" includeGroup "com.github.llamalad7.mixinextras" includeGroup "dev.onyxstudios.cardinal-components-api" } } maven { name = "LDT Team minecolonies" url = "https://ldtteam.jfrog.io/ldtteam/modding" content { includeGroup "com.ldtteam" } } maven { name = "Modmaven Jei" url = "https://modmaven.dev" content { includeGroup "mezz.jei" includeGroup "appeng" includeGroup "mekanism" } } maven { name = "Create" url = "https://maven.tterrag.com" content { includeGroup "com.simibubi.create" includeGroup "com.jozufozu.flywheel" includeGroup "com.tterrag.registrate" } } maven { name = "Fabric Create" url = "https://mvn.devos.one/snapshots" content { includeGroup "com.simibubi.create" includeGroup "com.tterrag.registrate_fabric" includeGroup "io.github.fabricators_of_create.Porting-Lib" includeGroup "io.github.tropheusj" } } maven { name = "Fabric Create Porting Lib" url = "https://mvn.devos.one/releases" content { includeGroup "io.github.fabricators_of_create.Porting-Lib" } } maven { name = "Forge Config API Port" url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven" content { includeGroup "fuzs.forgeconfigapiport" } } maven { name = "SirEdvin's private repository" url = "https://repo.repsy.io/mvn/siredvin/default" content { includeGroup "site.siredvin.ttoolkit" } } maven { name = "Shedaniel cloth" url = "https://maven.shedaniel.me" content { includeGroup "dev.architectury" includeGroup "me.shedaniel.cloth" } } // maven { // url = uri("https://maven.pkg.github.com/refinedmods/refinedstorage") // credentials { // username = "anything" // password = "\u0067hp_oGjcDFCn8jeTzIj4Ke9pLoEVtpnZMP4VQgaX" // } // content { // includeModule("com.refinedmods", "refinedstorage") // } // } exclusiveContent { forRepository { maven { name = "Modrinth" url = "https://api.modrinth.com/maven" } } filter { includeGroup "maven.modrinth" } } exclusiveContent { forRepository { maven { name = "CurseForge" url = "https://cursemaven.com" } } filter { includeGroup "curse.maven" } } } configurations { configureEach { resolutionStrategy { force("net.fabricmc:fabric-loader:${fabric_loader_version}") } } implementationExtra testModImplementation.extendsFrom(implementation) testModImplementation.extendsFrom(testImplementation) } dependencies { // If some of the dependencies are not needed in the dev environment, you can comment the `runtimeOnly` line so it // will not be included in the client. // Minimal requirements compileOnly "org.jetbrains:annotations:${jb_annotations}" minecraft "com.mojang:minecraft:${minecraft_version}" mappings "net.fabricmc:yarn:${yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" modCompileOnly "cc.tweaked:cc-tweaked-${minecraft_version}-fabric-api:${cc_version}" modRuntimeOnly "cc.tweaked:cc-tweaked-${minecraft_version}-fabric:${cc_version}" // Compile-time API required // Ae2 modImplementation "appeng:appliedenergistics2-fabric:${appliedenergistics_version}" // Curios modImplementation "dev.emi:trinkets:${trinkets_version}" // Minimal requirements end // Extended requirements // // We don"t use the api since we need a specific class from mekanism // compileOnly fg.deobf("mekanism:Mekanism:${mekanism_version}") // runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}") // runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")// core // Applied Energistics 2 modCompileOnly "appeng:appliedenergistics2-fabric:${appliedenergistics_version}" modRuntimeOnly "appeng:appliedenergistics2-fabric:${appliedenergistics_version}" // // Applied Mekanistics // implementation fg.deobf("curse.maven:applied-mekanistics-574300:${appliedmekanistics_version}") // Curios modRuntimeOnly "dev.emi:trinkets:${trinkets_version}" // // Refined Storage // implementation fg.deobf("com.refinedmods:refinedstorage:${refinedstorage_version}") { // transitive false // } // // AE2 Things // compileOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources") // runtimeOnly fg.deobf("curse.maven:ae2things-609977:${ae2things_version}-sources") // // AE2 Additions // compileOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}") // runtimeOnly fg.deobf("curse.maven:ae-additions-493962:${ae2additions_version}") // implementation fg.deobf("thedarkcolour:kotlinforforge:${kotlinforforge_version}") // Botania modCompileOnly "vazkii.botania:Botania:${botania_version}" modRuntimeOnly "vazkii.botania:Botania:${botania_version}" // // Minecolonies // // Remove/Comment this section if you want to use runData. // //runtimeOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}") // //runtimeOnly fg.deobf("com.ldtteam:structurize:${structurize_version}") // //runtimeOnly fg.deobf("com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal") // //runtimeOnly fg.deobf("com.ldtteam:blockui:${blockui_version}") // compileOnly fg.deobf("com.ldtteam:minecolonies:${minecolonies_version}") // compileOnly fg.deobf("com.ldtteam:structurize:${structurize_version}") // compileOnly fg.deobf("com.ldtteam:domum_ornamentum:${domumornamentum_version}:universal") // compileOnly fg.deobf("com.ldtteam:blockui:${blockui_version}") // Patchouli modRuntimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}-FORGE" // Create modCompileOnly "com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}" modRuntimeOnly "com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}" // // Powah // implementation fg.deobf("curse.maven:powah-633483:${powah_version}") // implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:11.1.106") // implementation fg.deobf("dev.architectury:architectury-forge:9.1.10") // Removed until fully ported //testImplementation fg.deobf("site.siredvin.ttoolkit:ttoolkit-${minecraft_version}:${ttoolkit_version}") testImplementation "org.junit.jupiter:junit-jupiter-api:${junit_version}" testImplementation "org.junit.jupiter:junit-jupiter-params:${junit_version}" testImplementation "org.hamcrest:hamcrest:${hamcrest_version}" testImplementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}" testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${kotlinx_coroutines_version}" testModImplementation sourceSets.main.output testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junit_version}" // Testing stuff // JEI modImplementation "mezz.jei:jei-${jei_version}" // Create Crafts & Additions modCompileOnly "curse.maven:createaddition-439890:${createadditions_version}" modRuntimeOnly "curse.maven:createaddition-439890:${createadditions_version}" } changelog { version = "${project.version}" path = "${project.projectDir}/CHANGELOG.md" header = "[${minecraft_version}-${-> version.get()}] - ${new SimpleDateFormat("yyyy-MM-dd").format(new Date())}" //Valid patterns would be //1.16.5-1.1.1.1b //1.18-1.0r //1.19-1.0.0a headerParserRegex = ~/\d+(\.\d+){1,2}-\d+(\.\d+){1,3}\w/ itemPrefix = "-" keepUnreleasedSection = true unreleasedTerm = "[Unreleased]" groups = [] } compileTestModJava { dependsOn(compileJava) } task setupServer(type: Copy) { group "test server" description "Sets up the environment for the test server." from("src/testMod/server-files") { include "eula.txt" include "server.properties" } into "test-files/server" } // ["Client", "Server"].forEach { name -> // tasks.register("test$name", JavaExec.class).configure { // it.group("In-game tests") // it.description("Runs tests on a temporary Minecraft instance.") // it.dependsOn(setupServer, "prepareRunTest$name", "cleanTest$name", "compileTestModJava") // JavaExec exec = tasks.getByName("runTest$name") // exec.copyTo(it) // it.setClasspath(exec.getClasspath()) // it.mainClass = exec.mainClass // it.setArgs(exec.getArgs()) // // it.systemProperty("forge.logging.console.level", "debug") // it.systemProperty("ttoolkit.run", "true") // } // } test { useJUnitPlatform() testLogging { events "skipped", "failed" } } afterEvaluate { // tasks.withType(JavaCompile) { // // options.compilerArgs << "-Xmaxerrs" << "2000" // options.compilerArgs << "-Xmaxerrs" << "20" // } } jar { from("LICENSE") { rename { "${it}_${base.archivesName.get()}"} } } tasks.withType(Checkstyle) { reports { xml.required = false html.required = false } // Checkstyle is compatible with the configuration cache, however we need to disable it to prevent a build issue with teamcity notCompatibleWithConfigurationCache() outputs.upToDateWhen { false } } tasks.named("processResources", ProcessResources).configure { var replaceProperties = [minecraft_version : minecraft_version, neo_version : neo_version, neo_loader_version : neo_loader_version, fabric_loader_version : fabric_loader_version, fabric_api_version : fabric_api_version, mod_id : mod_id, version : version, cc_version : cc_version, curios_version : curios_version, minecolonies_version : minecolonies_version, appliedenergistics_version: appliedenergistics_version, patchouli_version : patchouli_version, refinedstorage_version : refinedstorage_version, botania_version : botania_version, mekanism_version : mekanism_version, ae2things_version : ae2things_version, powah_version : powah_version,] inputs.properties replaceProperties filesMatching(["META-INF/mods.toml", "pack.mcmeta", "fabric.mod.json"]) { expand replaceProperties + [project: project] } } // Used to do some magic with teamcity task commitAndPush() { doLast { def baseMessage = project.hasProperty("commitMessage") ? commitMessage : "No commit message provided" def message = baseMessage.replace("{version}", "${minecraft_version}-${version}") exec { commandLine "git", "add", "." } exec { commandLine "git", "commit", "-m", message } } } tasks.register("publishCurseForge", TaskPublishCurseForge, { task -> setGroup("publishing") setDescription("Upload Advanced Peripherals to CurseForge") // This token is used to authenticate with CurseForge. It should be handled // with the same level of care and security as your actual password. You // should never share your token with an untrusted source or publish it // publicly to GitHub or embed it within a project. The best practice is to // store this token in an environment variable or a build secret. apiToken = curseforgeKey // Tells CurseForgeGradle to publish the output of the jar task. This will // return a UploadArtifact object that can be used to further configure the // file. task.upload(431725, jar) { file -> try { file.changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}" file.changelogType = "markdown" } catch (err) { System.out.println(err) file.changelog = "" } // addOptional("applied-energistics-2", "curios", "mekanism", "refined-storage") addOptional("applied-energistics-2", "trinkets") addRequirement("cc-tweaked") // addModLoader("forge", "neoforge") addModLoader("addModLoader") releaseType = "${release_type}" } }) githubRelease { releaseAssets = jar.archiveFile if (githubKey != null) token = githubKey owner = "IntelligenceModding" repo = "AdvancedPeripherals" tagName = "${minecraft_version}-${version}" releaseName = "${minecraft_version}-${version}" targetCommitish = "release/${minecraft_version}" generateReleaseNotes = false try { body = "${project.changelog.get("${minecraft_version}-${version}").withHeader(false).toText()}" } catch (err) { System.out.println(err) body = "" } draft = false prerelease = !release_type.equalsIgnoreCase("release") } modrinth { token = modrinthKey projectId = "SOw6jD6x" versionNumber = "${minecraft_version}-${project.version}" versionName = "Advanced Peripherals ${minecraft_version} ${version}" versionType = release_type uploadFile = jar gameVersions = [minecraft_version] loaders = ["fabric"] dependencies { required.project "cc-tweaked" } try { changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}" } catch (err) { System.out.println(err) changelog = "" } } publishing { publications { PublicationContainer publicationContainer -> publicationContainer.register("maven", MavenPublication) { MavenPublication publication -> publication.from((SoftwareComponent) components.java) publication.groupId = project.group publication.version = isSnapshotVersion ? "${minecraft_version}-${version}-${project.teamcityBuild}" : "${minecraft_version}-${version}" publication.artifactId = isSnapshotVersion ? "advancedperipherals-snapshots" : "advancedperipherals" publication.artifacts = [jar] publication.pom { name.set("AdvancedPeripherals") packaging = "jar" description.set("Advanced Peripherals provides multiple extensions for ComputerCraft in form of Peripherals, Pocket Upgrades, Turtles or new gear.\n" + "It also integrates with multiple third party mods.") url.set("https://docs.intelligence-modding.de/") scm { url.set("https://github.com/SirEndii/AdvancedPeripherals.git") } issueManagement { system.set("github") url.set("https://github.com/SirEndii/AdvancedPeripherals/issues") } licenses { license { name.set("Apache-2.0") distribution.set("repo") } } withXml { NodeList dependencies = asNode().dependencies NodeList allDeps = dependencies."*" //TODO: Needs to be changed in 1.20.2 since neoforge then changes the packages names. // Remove forge deps allDeps. findAll() { Node el -> el.artifactId.text() == "forge" && el.groupId.text() == "net.minecraftforge" }.forEach() { Node el -> el.parent().remove(el) } //remove ForgeGradle"s mapped suffix from versions & set as optional so anyone else doesn"t inherit them allDeps. findAll() { Node el -> el.version.text().contains("_mapped_") }.each { Node el -> el.version.each { Node version -> def versionText = version.text() version.setValue(versionText.substring(0, versionText.indexOf("_mapped_"))) } el.appendNode("optional", true) } } } } } repositories { maven { name = "public" url = "https://mvn.intelligence-modding.de/Intelligence" credentials { username = repositoryName password = repositoryKey } } } } ```
zyxkad commented 1 month ago

Alr after disabled some plugins, I found org.gradle.toolchains.foojay-resolver-convention which defined in the settings.gradle causes this problem.

modmuss50 commented 1 month ago

This is a Gradle bug, the work around is to update the foojay plugin. There is nothing we can do about this.