neoforged / ModDevGradle

A Gradle plugin for developing Minecraft mods using NeoForge
https://projects.neoforged.net/neoforged/moddevgradle
GNU Lesser General Public License v2.1
21 stars 3 forks source link

neoForge mods block dependency uses src directly #60

Open MerchantPug opened 1 week ago

MerchantPug commented 1 week ago

Hi, when using a dependency on another project in MDG, it will use the src directly, rather than build/resources or build/classes like how sourceSet does.

This is an issue for cases where a user may modify their neoforge.mods.toml through Gradle, or bring in another project's code into a build (such as how the Multiloader Template brings the common code directly into the NeoForge build).

com.electronwill.nightconfig.core.io.ParsingException: Invalid bare key: ${mod_id}_entity
MerchantPug commented 1 week ago

I have also tried using sourceSet instead of dependency. Which doesn't work, due to the below:

A problem occurred configuring project ':neoforge'.
> Failed to query the value of property 'modFolders'.
   > Failed to query the value of property 'mods'.
      > Could not create domain object 'effectapi_base' (ModModel)

    mods {
        register("effectapi") {
            sourceSet(sourceSets["main"])
        }
        register("effectapi_test") {
            sourceSet(sourceSets["test"])
        }
        register("effectapi_base") {
            sourceSet(project(":base:base-neoforge").sourceSets["main"])
        }
    }
shartte commented 1 week ago

Hi, when using a dependency on another project in MDG, it will use the src directly, rather than build/resources or build/classes like how sourceSet does.

This is an issue for cases where a user may modify their neoforge.mods.toml through Gradle, or bring in another project's code into a build (such as how the Multiloader Template brings the common code directly into the NeoForge build).

com.electronwill.nightconfig.core.io.ParsingException: Invalid bare key: ${mod_id}_entity

Have you set your IDE to build using IntelliJ? If that is the case, you cannot use processResources in that way, since IntelliJ will not run the task, and instead copy the resources itself. If you want to use processResources, you'll have to set IJ to build using Gradle, which will then use build/resources et al.

MerchantPug commented 1 week ago

I have it set to build using Gradle.

I think I have failed to mention what I was doing. The main issue is that the below mods using dependency, do not resolve,

mods {
        register("effectapi") {
            sourceSet(sourceSets["main"])
        }
        register("effectapi_test") {
            sourceSet(sourceSets["test"])
        }
        register("effectapi_base") {
            dependency(project(":base:base-neoforge"))
        }
        register("effectapi_entity") {
            dependency(project(":entity:entity-neoforge"))
        }
    }
MerchantPug commented 1 week ago

Here is the mod folders argument for my runs, generated by MDG. as you can see, it seems to use build/resources for the two using sourceSet, but does not use this for the ones marked with dependency

-Dfml.modFolders=effectapi_test%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\classes\\java\\test;effectapi_test%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\resources\\test;effectapi_entity%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\entity\\neoforge\\src\\main\\resources;effectapi_entity%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\entity\\neoforge\\src\\main\\java;effectapi_entity%%C:\\Users\\User\\.gradle\\caches\\modules-2\\files-2.1\\org.jetbrains\\annotations\\24.1.0\\7af6a669488450c4a07c2c3254e2151df42d7d04\\annotations-24.1.0.jar;effectapi_base%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\base\\neoforge\\src\\main\\resources;effectapi_base%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\base\\neoforge\\src\\main\\java;effectapi_base%%C:\\Users\\User\\.gradle\\caches\\modules-2\\files-2.1\\org.jetbrains\\annotations\\24.1.0\\7af6a669488450c4a07c2c3254e2151df42d7d04\\annotations-24.1.0.jar;effectapi%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\classes\\java\\main;effectapi%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\resources\\main
shartte commented 1 week ago

Here is the mod folders argument for my runs, generated by MDG. as you can see, it seems to use build/resources for the two using sourceSet, but does not use this for the ones marked with dependency

-Dfml.modFolders=effectapi_test%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\classes\\java\\test;effectapi_test%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\resources\\test;effectapi_entity%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\entity\\neoforge\\src\\main\\resources;effectapi_entity%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\entity\\neoforge\\src\\main\\java;effectapi_entity%%C:\\Users\\User\\.gradle\\caches\\modules-2\\files-2.1\\org.jetbrains\\annotations\\24.1.0\\7af6a669488450c4a07c2c3254e2151df42d7d04\\annotations-24.1.0.jar;effectapi_base%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\base\\neoforge\\src\\main\\resources;effectapi_base%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\base\\neoforge\\src\\main\\java;effectapi_base%%C:\\Users\\User\\.gradle\\caches\\modules-2\\files-2.1\\org.jetbrains\\annotations\\24.1.0\\7af6a669488450c4a07c2c3254e2151df42d7d04\\annotations-24.1.0.jar;effectapi%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\classes\\java\\main;effectapi%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\resources\\main

That is very weird. Do you have this project somewhere on GH so I can take a look? Otherwise I'll make a test project myself.

MerchantPug commented 1 week ago

Here is the mod folders argument for my runs, generated by MDG. as you can see, it seems to use build/resources for the two using sourceSet, but does not use this for the ones marked with dependency

-Dfml.modFolders=effectapi_test%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\classes\\java\\test;effectapi_test%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\resources\\test;effectapi_entity%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\entity\\neoforge\\src\\main\\resources;effectapi_entity%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\entity\\neoforge\\src\\main\\java;effectapi_entity%%C:\\Users\\User\\.gradle\\caches\\modules-2\\files-2.1\\org.jetbrains\\annotations\\24.1.0\\7af6a669488450c4a07c2c3254e2151df42d7d04\\annotations-24.1.0.jar;effectapi_base%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\base\\neoforge\\src\\main\\resources;effectapi_base%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\base\\neoforge\\src\\main\\java;effectapi_base%%C:\\Users\\User\\.gradle\\caches\\modules-2\\files-2.1\\org.jetbrains\\annotations\\24.1.0\\7af6a669488450c4a07c2c3254e2151df42d7d04\\annotations-24.1.0.jar;effectapi%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\classes\\java\\main;effectapi%%C:\\Users\\User\\Desktop\\Programs\\MCMods\\effect-api\\neoforge\\build\\resources\\main

That is very weird. Do you have this project somewhere on GH so I can take a look? Otherwise I'll make a test project myself.

https://github.com/GreenhouseTeam/effect-api

This has two issues.

  1. Not bringing in the common code to runs through gradle, this leads to class not found exceptions unless I use implementation on the common project.
  2. processResources doesn't function, leading to the error I wrote above.

There's probably more fluff in this project, so feel free to use either this or your own reproduction.