SleepyTrousers / EnderIO-1.5-1.12

http://enderio.com/
The Unlicense
729 stars 360 forks source link

Resolving resource duplication in modules #4409

Closed MatanShahar closed 6 years ago

MatanShahar commented 6 years ago

Apparently I like opening issues. Well this issue is somewhat, if not complex, large.

Abstract

Up until now all the 1.11 modules where built separately so name duplication was fine. The problem appears when merging all the modules into one jar. Since a jar is an archive it can't have duplicate paths at all, this means that resource duplication will, and is failing builds.

Risk management

Why this issue needs to be resolved

As it stands the issue does not affect current builds and does not cause any unexpected behavior that we are aware of. The only thing this issue affects currently is the future of the project's release strategy, if we choose to release as with a combined 'jar' file with all the modules this issue must be addressed.

Cost of resolving this issue

This is definitely a large issue and solving it will take up development time and may delay the 1.11 release. Additionally it is very hard to validate, since it involved resource object and not code all references to them are strings so the compiler is of no use. These objects are accessed throughout the codebase in many classes and many new bugs may be introduced.

Resolution strategies

The following are the different possible ways of resolving the issue.

Migrating all resources to base

Theoretically it should be possible to move all the resources back into one module (base) and call it a day.

Effort: medium

Maintainability: low

Reliability: high

Customizing the build to merge resources

It may be possible to use the build engine (gradle) to merge the resources on build.

Effort: high

Maintainability: modium

Reliability: medium

Additionally I think this strategy is very risky, over time it will be forgotten and no one will know how to fix the same issues we are having now.

Moving the resources to separate domains

This is the real solution to the problem - giving each module its own resource domain.

Effort: high

Maintainability: infinite

Reliability: high

Risks:

Alternatives

Are there any alternatives to resolving this issue?

JoduWei commented 6 years ago

No matter how you decide, I can help if you tell me how. Copy files, fixing references etc.

HenryLoenwind commented 6 years ago

Let me give you a tiny bit of history. All projects are using the the DOMAIN, and that is not an accident but was done on purpose. I would have preferred for them to use their own modid as domain, but there are too many places that want to add a domain to something, or where Forge decides for you which domain is the right one. You see all those hundreds of warnings about a wrong domain at startup? That is there because I changed the modid of the main project to "enderiobase". I did that to provoke those errors, so I can see if something is wrong. Quite soon I will change the modid of enderiobase back to match the domain.

So, resource merging is the only way to go. Give me a moment to make a list of all conflicting files. There shouldn't be that many.

HenryLoenwind commented 6 years ago

Not too many, (Yes, I de-duped resources recently)

Strategies:

pack.mcmeta and recipes.xsd can be taken from ' base'. All submods must(!) have identical(!) copies.

*.lang files can simply be concatenated.

sounds.json and mcmod.info need to be merged. Merging strategy is relatively simple (drop first/last line, add a comma).

MatanShahar commented 6 years ago

Now that each module is really a different project why would Forge decide on a wrong domain? It's pretty much the same as TE having different repositories. I really would like to avoid the merging option because I have no idea how to do this or even if that's possible.

HenryLoenwind commented 6 years ago

Because Forge keeps track of which Mod's code is currently running. While you can supply resources for any domain in jour jar, once you register objects with Forge you must supply the correct ID for whatever code Forge started. And from that ID is derived which resources will be loaded for it.

So if the ModObjectRegistry registers a block, that block must have an ID of "enderiobase" or we get that nice warning we see at the moment. Same for registering the sounds. If we want our central sound registry to handle that (and don't want to make a copy of it in each submod), they all need to be defined in asset/enderio/sounds.json. The .oggs themselves could be anywhere, as could the textures (Forge doesn't care what resources are used by resources, only about the initial one). But those don't conflict...