I’m trying to setup a Forge development environment with Sponge installed so that I can develop Sponge plugins that use parts of the Forge API. An older post I found on the forums said that this could be achieved by setting it up as a subproject. I tried to do this with the current Sponge repository’s HEAD but when I run build.gradle in the root project, I get the error in the title, but not when I run the Sponge project’s build.gradle, which works just fine.
Here is my settings.gradle
rootProject.name = "(Insert name here)"
include "Sponge"
include "Sponge:SpongeCommon"
include "Sponge:SpongeCommon:SpongeAPI"
So that’s obviously not the problem… I just can’t figure this out.
I’ve tried deleting the settings.gradle inside the subprojects, I’ve tried removing the line in the Sponge build.gradle (caused shadowJar<> error instead) and I’ve also tried using…
apply from: new File("SpongeCommon/gradle/implementation.gradle")
I’ve just tried creating a symbolic link to the Gradle file referenced by the Sponge build script and editing the build script to try to include that file instead, but the same error occurred.
Gradle seems to think that SpongeCommon is an invalid Gradle project when the root project is my project, but not when it’s the Sponge project.
You’re including the Sponge project as a submodule and the build files were really not written to work in this situation. I ended up fixing the issue with the following redirection abomination:
include ':Sponge'
include ':SpongeCommon'
include ':SpongeCommon:SpongeAPI'
def dir = rootProject.projectDir
dir = (project(':Sponge').projectDir = new File(dir, "Sponge"))
dir = (project(':SpongeCommon').projectDir = new File(dir, "SpongeCommon"))
project(':SpongeCommon:SpongeAPI').projectDir = new File(dir, "SpongeAPI")
This forcibly defines the subprojects that the build-files expect and sets the appropriate project directories for each of them, assuming Sponge is included through git submodules (recursively included)
That didn’t fix it. Now it says it can’t find SpongeCommon. SpongeCommon is inside Sponge, must I add, which your fix doesn’t seem to notice.
If I don’t load Sponge like that, I can’t test inside the development environment because of the mixins (unless if someone will add a build that does not obfuscate the mixins).
Edit: Gradle is weird, first time I tried your fix I only copied the 4 last lines of it. But the whole fix works. Thank you.
Mixin failed applying mixins.common.core.json:server.MixinServerConfigurationManager -> net.minecraft.server.management.ServerConfigurationManager: org.spongepowered.asm.mixin.transformer.InvalidMixinException Shadow method setPlayerGameTypeBasedOnOther was not located in the target class
This happens when I try to run the Sponge server in the development environment. Indeed FerusGrim, what have I done?
I checked the class file and it does not contain the method setPlayGameTypeBasedOnOther, yet I am using the version of Forge that Sponge is referencing, so this error shouldn’t be, unless if it errors in the Sponge development environment too (if so, could someone give me a functional commit #?)
That’s weird. It runs if the project is set to “Sponge”, but not if it’s set to my plugin project.
It’s a bit annoying because if I run it with the project set to “Sponge”, the dependencies and my project aren’t ran too. I think I’m going to take a look at the Sponge build script…
Edit: It turns out that more methods are deobfuscated in the Sponge’s forgeSrc, but I don’t see why MCP didn’t deobfuscate them in my case too since I’m running the same version of Forge as the Sponge plugin is configured to.