rossturner / king-under-the-mountain

A simulation-based strategy game written in Java using LibGDX
MIT License
106 stars 17 forks source link

Some JSON/CSV is (re)generated on every build, causing Git churn #27

Open nanodeath opened 3 months ago

nanodeath commented 3 months ago

There's a few[1] files in assets/ that seem to get regenerated on every build or something. There's probably some optimization possible to not to that, or do that smarter or something, but the main pain point for me is the Git churn; generated files generally shouldn't be in source control.

The most logical option to me would be to update their paths to be core/assets/generated/* and then add that to .gitignore, but there might be a better way.

(ignore GlobalSettings.java there) 1: image

nanodeath commented 3 months ago

This seems to happen around here:

https://github.com/rossturner/king-under-the-mountain/blob/969f4ebc4633137c653e92f59329b2e627de7941/core/src/main/java/technology/rocketjump/undermount/AssetsPackager.java#L165

I thought perhaps I could just read in what was already on disk and write it back if it's different, but sometimes the data is in a different order:

image

Maybe that data was not used LinkedHashMap before and now it is, or...something else. If we know these lists aren't actually order-sensitive, we could sort them and then compare, but we'd have to do that recursively, which would be a pain. If we're operating on Jackson nodes instead of custom types, it wouldn't be quite as bad, but still a bit mind-numbing :slightly_smiling_face:

The better long-term fix here would be basically to avoid writing back into assets at runtime at all; treat it as read-only. I'm going to see about writing these back into the application's write area (which at least on Linux is currently directly under the home directory?? but that's another issue), and then update whatever's reading these files to check both locations.