From cc51c64c37fe40c3df9e0ecbf1b2ea56344fd025 Mon Sep 17 00:00:00 2001 From: modmuss Date: Sun, 29 Dec 2024 15:56:17 +0000 Subject: [PATCH] Fix #1229 (#1237) --- .../configuration/CompileConfiguration.java | 4 +++ .../MojangMappingsProjectTest.groovy | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/net/fabricmc/loom/configuration/CompileConfiguration.java b/src/main/java/net/fabricmc/loom/configuration/CompileConfiguration.java index 93c34b56a..c4489640b 100644 --- a/src/main/java/net/fabricmc/loom/configuration/CompileConfiguration.java +++ b/src/main/java/net/fabricmc/loom/configuration/CompileConfiguration.java @@ -166,9 +166,13 @@ private synchronized void setupMinecraft(ConfigContext configContext) throws Exc extension.setMinecraftProvider(minecraftProvider); minecraftProvider.provide(); + // Realise the dependencies without actually resolving them, this forces any lazy providers to be created, populating the layered mapping factories. + project.getConfigurations().getByName(Configurations.MAPPINGS).getDependencies().toArray(); + // Created any layered mapping files. LayeredMappingsFactory.afterEvaluate(configContext); + // Resolve the mapping files from the configuration final DependencyInfo mappingsDep = DependencyInfo.create(getProject(), Configurations.MAPPINGS); final MappingConfiguration mappingConfiguration = MappingConfiguration.create(getProject(), configContext.serviceFactory(), mappingsDep, minecraftProvider); extension.setMappingConfiguration(mappingConfiguration); diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/MojangMappingsProjectTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/MojangMappingsProjectTest.groovy index 086778ada..4669f362d 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/MojangMappingsProjectTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/MojangMappingsProjectTest.groovy @@ -120,4 +120,30 @@ class MojangMappingsProjectTest extends Specification implements GradleProjectTe where: version << STANDARD_TEST_VERSIONS } + + @Unroll + def "mojang mappings via lazy provider (gradle #version)"() { + setup: + def gradle = gradleProject(project: "minimalBase", version: version) + + gradle.buildGradle << ''' + dependencies { + minecraft "com.mojang:minecraft:1.18-pre5" + mappings project.provider { + loom.layered() { + officialMojangMappings() + } + } + } + ''' + + when: + def result = gradle.run(task: "build") + + then: + result.task(":build").outcome == SUCCESS + + where: + version << STANDARD_TEST_VERSIONS + } }