#Loom prevents me from running datagen on CI

18 messages · Page 1 of 1 (latest)

obsidian hearth
#

I'm having an annoying issue when trying to have data generation in a separate sourceset, and it's blocking me from running datagen in my CI
Server/client sourcesets work wonderfully but this one is bugging out because it requires to be set to a different ID in the loom configuration:

loom {
    splitEnvironmentSourceSets()

    mods {
        "promenade" {
            sourceSet sourceSets.main
            sourceSet sourceSets.client
        }
    }
}

fabricApi {
    configureDataGeneration() {
        modId = "promenade-datagen" // Cannot be "promenade"
        createSourceSet = true
        client = true
    }
}

When doing so, neither the generated IDE run configuration (on IntelliJ) or the gradlew runDatagen command run my data generation. Even if I override DataGeneratorEntrypoint#getEffectiveModId. It just does not hit the entry point.

My solution was to modify the run configuration (image 3). I set -Dfabric-api.datagen.modid to my actual mod ID. This does effectively generate all of my data to src/main/generated as I wished.

Nevertheless, I still cannot run the command and therefore cannot properly build the mod from my CI. (please note that I do not commit my generated data)

obsidian hearth
#

I have some temporary solutions in my mind:

  • run the runDatagen command in my CI with -Dfabric-api.datagen.modid set to my actual mod ID before build
  • ditch the datagen module and put all of my datagen code in the main module. That will however ship the mod with all the datagen code, that may not be needed for the users
wind patio
#

Pretty sure you need to add a dummy fabric.mod.json to the datagen source set to make fabric load it.

gritty socket
#

datagen sourceset works fine with the normal modid. it also works fine with modId set and no fmj

#

you may have to remove teh

    mods {
        "promenade" {
            sourceSet sourceSets.main
            sourceSet sourceSets.client
        }
    }
``` section
jagged moss
#

Yes, in your datagen sourceset you need a seperate fabric.mod.json that has just the datagen entrypoint.

obsidian hearth
#

Ah! Simple as that

#

Thank you very much!

#

I deleted my "warning" in #loom. 😄

#

As for my CI, I am trying to run gradlew runDatagen build instead of gradlew build but I'm having this error:

Gradle detected a problem with the following location: 'D:\Code\Projects\MinecraftModding\Promenade\src\main\generated'.
Reason: Task ':sourcesJar' uses this output of task ':runDatagen' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

So I've tried adding this to my gradle.build: ```gradle
sourcesJar {
from("src/main/generated") {
exclude ".cache"
}
}


Same thing happens
jagged moss
#

You need to run them as 2 commands, this boils down to a fundamental issue where to run datagen you need to build main, but to build main you want it to have the data generated files. The other option is to commit the datagened files to the repo.

obsidian hearth
#

Ah yeah, that makes perfect sense actually

#

Hopefully that does the trick

jagged moss
obsidian hearth
#

Oh, really? I don't remember why I had that

jagged moss
#

clean deletes the build folder where a lot of your project outputs are stored, if you dont delete them they can be reused from the previous run.

obsidian hearth
#

Hm, well my CI uses the mc-publish action aftewards. I think it actually uploads everything found in the build folder, since it also uploads my source
I hope it doesn't upload my previous versions too 😅