neoforged / MDK

The Mod Developer Kit - this is where you start if you want to develop a new mod
https://github.com/NeoForgeMDKs
185 stars 59 forks source link

Remove project from resource processing template replacement #45

Closed lukebemish closed 6 months ago

lukebemish commented 6 months ago

The template-expanding done in processResources currently contains:

filesMatching(['META-INF/mods.toml']) {
    expand replaceProperties + [project: project]
}

This causes issues with configuration caching - in addition to those already caused by neogradle - as it uses the project object within template expansion; to reach the eventual goal of working configuration caching in a userdev environment, this should be resolved. Specifically, the error is (if you disable the neogradle features that themselves cause failures):

luke@luke-kubuntu:~/src/test/MDK$ ./gradlew build --configuration-cache
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.6/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build 
Reusing configuration cache.
> Task :processResources FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/home/luke/src/test/MDK/build.gradle' line: 122

* What went wrong:
Execution failed for task ':processResources'.
> Cannot reference a Gradle script object from a Groovy closure as these are not supported with the configuration cache.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 3s
1 actionable task: 1 executed
Configuration cache entry reused.

Luckily, this expansion isn't actually used anywhere - so the issue can be resolved by only using replaceProperties without the added project expansion.

lukebemish commented 6 months ago

Fixed up the alignment