fabric-loader icon indicating copy to clipboard operation
fabric-loader copied to clipboard

Treat unexpanded Gradle version property as satisfied dependency

Open jackassmc opened this issue 4 years ago • 10 comments

This helps when testing mod compatibility with mods that have a dependency on the mod that is being developed.

jackassmc avatar Jun 24 '21 14:06 jackassmc

Another solution would be to set the gradle version from the mod json.

modmuss50 avatar Jun 24 '21 14:06 modmuss50

Do you mean loading the version from gradle.properties in ModMetadataParser?

jackassmc avatar Jun 24 '21 15:06 jackassmc

The main problem is that people can use any custom token for substitution; nothing prevents them from using ${myKey} if they do replacement of myKey in processResources. Hence I prefer modmuss' suggestion, which will make some change to the example mod instead, so its gradle buildscript pulls the version from fabric.mod.json.

liach avatar Jun 24 '21 15:06 liach

Gradle has a json parser - you can simply read the file and set the version. Alternatively, you can run processResources before launch. Personally, I use the latter.

dexman545 avatar Jun 24 '21 15:06 dexman545

This was also previously discussed in https://github.com/FabricMC/fabric-loader/pull/359

dexman545 avatar Jun 24 '21 15:06 dexman545

The best solution would be to make the generated minecraft run configuration run the gradle processResources task and use that resources indeed, which is the behavior of gradle runClient

liach avatar Jun 24 '21 15:06 liach

Gradle has a json parser - you can simply read the file and set the version.

Ah that sounds even better. I'll make a PR for the example mod.

jackassmc avatar Jun 24 '21 15:06 jackassmc

Fyi I sent a pr, and that works good per my testing

liach avatar Jun 24 '21 16:06 liach

I think I want to do do two things here:

  1. change example mod to read the version from the json
  2. add a system property to loader to override the version based on mod id (needs to support more than 1 mod id+version pair ofc)

This way the default just works and the classic approach is fixable as well. I don't like the special casing used in this PR, implementing the option 2 from above should wait until my next big PR is in.

Player3324 avatar Jun 24 '21 19:06 Player3324

We now have various simple approaches:

  • use the actual version in fabric-mod.json, pull it into the build via version = loom.modVersion (handles all parsing, requires loom 0.10)
  • overwrite the version loader uses with the system property: -Dfabric.debug.replaceVersion=modA:versionA,modB:versionB,...
  • run through gradle as before

Player3324 avatar Oct 20 '21 21:10 Player3324