Gradle Project with path ':SpongeCommon' could not be found in project ':Sponge'

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")

But that just yielded the same error.

Did you initialize the git submodules?

1 Like

By calling

git init

in each submodule’s root?
Yes, I even updated them all. The files from SpongeCommon and SpongeAPI are all in their submodules.

Here’s a basic representation of the file system.

Project Root
    .git
        [git files, submodules is a valid directory here]
    Sponge
        SpongeCommon
            SpongeAPI
                build.gradle
                build.properties
                [other Gradle files]
            build.gradle
            build.properties
            [other Gradle files]
        build.gradle
        build.properties
        [other Gradle files]
    build.gradle
    settings.gradle
    [other Gradle files]

git submodule update --init --recursive

It’s all already done, @simon816

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)

Dear God. What have you done? ;_;

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.

The error has been fixed but now I get

Could not find implementation class 'nl.javadude.gradle.plugins.license.LicensePlugin'

It’s weird because I’ve checked the file, and it contains the class referenced in the META-INF, so it should find it.

Add

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
    }
}

to your own build.gradle, its weird but apparently gradle cannot resolve it by itself :expressionless:

Thanks again, Kiskae, that fixed it.

The way Gradle works doesn’t make much sense to me, I might look into it later…

I wish it wasn’t required, might need to look at how Sponge’s gradle files include their subprojects, because something seems off :wink:

Extra weirdness on the way: ‘§’ is not a valid character constant in SpongeAPI (compiler error) is this due to me using bad encoding or is it normal?

And I thought test code was meant to compile normally…

Your IDE has to be using the UTF-8 encoding.

Setting it to UTF-8 doesn’t fix it… It doesn’t matter because I ignored the errors and warnings for the Sponge projects.

Do I get bonus points for having broken it again?

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 #?)

I don’t see how that could be happening. Are you using the latest Sponge build? It works when I run sponge in an IDE.
The shadowed method has the same signature as it does in the MC source.
https://github.com/SpongePowered/SpongeCommon/blob/master/src/main/java/org/spongepowered/common/mixin/core/server/MixinServerConfigurationManager.java#L101

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.

Maybe your MCP mappings are out of date, Sponge uses this version:
https://github.com/SpongePowered/SpongeCommon/blob/master/gradle/minecraft.gradle#L20