MinecraftForge / ForgeGradle

Minecraft mod development framework used by Forge and FML for the gradle build system
GNU Lesser General Public License v2.1
508 stars 436 forks source link

ForgeGradle fails to find remapped mods with `exclusiveContent` repositories #925

Closed lukebemish closed 1 year ago

lukebemish commented 1 year ago

This may not be easily fixable with the current state of forgegradle, but I figured it was worth reporting so that it is documented. If you add a repository with mod dependencies with gradle's exclusiveContent filter (https://docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository) (which basically stops gradle from searching other repositories for stuff in a given group), and attempt to fg.deobf a mod from that repository, forge fails to find the deobfed dependency when genIntelliJRuns is ran. This is as forge's generated, remapped dependencies are in the same group that is filtered to only belong to the given repository - while I was able to figure this out, this would not be obvious to the average user or even someone with a bit of gradle knowledge but little knowledge of how forgegradle works.

pupnewfster commented 1 year ago

As of a while back it does you just have to include fg.repository as one of the repos the exclusive content can be found at. Can't link to specific lines of build.gradles super well from mobile but I wrote a twitter thread a while back when fg added support for it that showcased some helpers and the like I wrote that should contain enough code examples to see how to use exclusiveContent. https://twitter.com/pupnewfster/status/1638601379966074880?s=61&t=c-lOGetK6m2GaYuaICnrIw

pupnewfster commented 1 year ago

Now that I am back at my PC so can type a bit better of an explanation of the requirements for using exclusiveContent with ForgeGradle rather than just giving an example of how to use it the main difference is that as part of the exclusiveContent block (which is defining an ExclusiveContentRepository) you need to also define forge gradle's deobf repo using fg.repository via ExclusiveContentRepository#forRepositories. Looking at the implementation details of forRepositories it seems that it is additive so you can use the common forRepository system that gradle shows in their docs as an example and then after that somewhere else in the exclusiveContent block you just would need to add a forRepositories(fg.repository) and in theory it should just work. This basically just marks the deobf repo as a valid repo for the filter so that gradle can check both the repo you list in the block as well as the deobf repo.

lukebemish commented 1 year ago

This makes sense to me; I still think it might be better, if at all possible, to move forgegradle's remapped artifacts to their own group - that way this step is unnecessary, and adidtionally gradle doesn't scan other repositories for forgegradle's stuff (unless that is already avoided somehow). Thank you for the information though; that makes sense to me.