Fix lazily provided layered mappings causing crash #1229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The above is the configuration that caused the following crash.
Why is this behaviour wanted?
This allows people to use providers to define the mappings used by a project, for example, a gradle plugin that wraps Loom might define parchment via a extension property.
excuse the possible invalid groovy syntax, I am used to Kotlin DSL
Code analysis
During
setupMinecraft
inCompileConfiguration
:afterEvaluate
method prevents any further configuration being made to the layered spec vialoom.layered() {}
.loom.layered()
in the buildscript is now evaluated.Can you see the problem?
How did this work before?
Previously, Loom relied on the fact that the buildscript itself is evaluated before
setupMinecraft
. Which meant that if aloom.layered() {}
was called, it would happen before it was finalised.Using a provider exposed the problem: the layered spec is finalised before actually retrieving the dependency for mappings. The layered spec would finalise and THEN the provider would trigger, trying to call
loom.layered() {}
.The fix
The fix is simple, finalise the layered mappings factory AFTER retrieving the dependency. Just swap lines 1 and 2.
An integration test has been added to test for this.