Fix MojangMappingsSpec having the same hash version for each mc version.
I dont think this would be a real cause for concern as the jar would have had the mc version in it anyway.dev/0.11
parent
d32acb3370
commit
61fa4d9fb6
|
@ -75,9 +75,7 @@ public interface LoomGradleExtension extends LoomGradleExtensionAPI {
|
||||||
|
|
||||||
JarProcessorManager getJarProcessorManager();
|
JarProcessorManager getJarProcessorManager();
|
||||||
|
|
||||||
default MinecraftProviderImpl getMinecraftProvider() {
|
MinecraftProviderImpl getMinecraftProvider();
|
||||||
return getDependencyManager().getProvider(MinecraftProviderImpl.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
default MappingsProviderImpl getMappingsProvider() {
|
default MappingsProviderImpl getMappingsProvider() {
|
||||||
return getDependencyManager().getProvider(MappingsProviderImpl.class);
|
return getDependencyManager().getProvider(MappingsProviderImpl.class);
|
||||||
|
|
|
@ -30,15 +30,21 @@ import java.util.List;
|
||||||
|
|
||||||
import org.gradle.api.Action;
|
import org.gradle.api.Action;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec;
|
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec;
|
import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.parchment.ParchmentMappingsSpecBuilder;
|
import net.fabricmc.loom.configuration.providers.mappings.parchment.ParchmentMappingsSpecBuilder;
|
||||||
|
|
||||||
public class LayeredMappingSpecBuilder {
|
public class LayeredMappingSpecBuilder {
|
||||||
private final List<MappingsSpec<?>> layers = new LinkedList<>();
|
private final List<MappingsSpec<?>> layers = new LinkedList<>();
|
||||||
|
private final MinecraftProvider minecraftProvider;
|
||||||
|
|
||||||
|
public LayeredMappingSpecBuilder(MinecraftProvider minecraftProvider) {
|
||||||
|
this.minecraftProvider = minecraftProvider;
|
||||||
|
}
|
||||||
|
|
||||||
public LayeredMappingSpecBuilder officialMojangMappings() {
|
public LayeredMappingSpecBuilder officialMojangMappings() {
|
||||||
layers.add(new MojangMappingsSpec());
|
layers.add(new MojangMappingsSpec(minecraftProvider.minecraftVersion()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import net.fabricmc.loom.configuration.providers.mappings.MappingContext;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsSpec;
|
import net.fabricmc.loom.configuration.providers.mappings.MappingsSpec;
|
||||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
||||||
|
|
||||||
public record MojangMappingsSpec() implements MappingsSpec<MojangMappingLayer> {
|
public record MojangMappingsSpec(String minecraftVersion) implements MappingsSpec<MojangMappingLayer> {
|
||||||
// Keys in dependency manifest
|
// Keys in dependency manifest
|
||||||
private static final String MANIFEST_CLIENT_MAPPINGS = "client_mappings";
|
private static final String MANIFEST_CLIENT_MAPPINGS = "client_mappings";
|
||||||
private static final String MANIFEST_SERVER_MAPPINGS = "server_mappings";
|
private static final String MANIFEST_SERVER_MAPPINGS = "server_mappings";
|
||||||
|
|
|
@ -36,11 +36,12 @@ import org.gradle.api.artifacts.Dependency;
|
||||||
import org.gradle.api.file.ConfigurableFileCollection;
|
import org.gradle.api.file.ConfigurableFileCollection;
|
||||||
import org.gradle.api.plugins.BasePluginConvention;
|
import org.gradle.api.plugins.BasePluginConvention;
|
||||||
|
|
||||||
|
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
|
||||||
import net.fabricmc.loom.api.MixinApExtensionAPI;
|
import net.fabricmc.loom.api.MixinApExtensionAPI;
|
||||||
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
import net.fabricmc.loom.api.decompilers.LoomDecompiler;
|
||||||
import net.fabricmc.loom.api.LoomGradleExtensionAPI;
|
|
||||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
import net.fabricmc.loom.configuration.ide.RunConfigSettings;
|
||||||
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.GradleMappingContext;
|
import net.fabricmc.loom.configuration.providers.mappings.GradleMappingContext;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec;
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec;
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder;
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder;
|
||||||
|
@ -113,7 +114,7 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
|
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
|
||||||
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder();
|
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder(getMinecraftProvider());
|
||||||
action.execute(builder);
|
action.execute(builder);
|
||||||
LayeredMappingSpec builtSpec = builder.build();
|
LayeredMappingSpec builtSpec = builder.build();
|
||||||
return new LayeredMappingsDependency(new GradleMappingContext(getProject(), "layers_" + builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
|
return new LayeredMappingsDependency(new GradleMappingContext(getProject(), "layers_" + builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());
|
||||||
|
@ -182,6 +183,8 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||||
|
|
||||||
protected abstract MixinApExtension getMixinApExtension();
|
protected abstract MixinApExtension getMixinApExtension();
|
||||||
|
|
||||||
|
protected abstract MinecraftProvider getMinecraftProvider();
|
||||||
|
|
||||||
// This is here to ensure that LoomGradleExtensionApiImpl compiles without any unimplemented methods
|
// This is here to ensure that LoomGradleExtensionApiImpl compiles without any unimplemented methods
|
||||||
private final class EnsureCompile extends LoomGradleExtensionApiImpl {
|
private final class EnsureCompile extends LoomGradleExtensionApiImpl {
|
||||||
private EnsureCompile() {
|
private EnsureCompile() {
|
||||||
|
@ -203,5 +206,10 @@ public abstract class LoomGradleExtensionApiImpl implements LoomGradleExtensionA
|
||||||
protected MixinApExtension getMixinApExtension() {
|
protected MixinApExtension getMixinApExtension() {
|
||||||
throw new RuntimeException("Yeah... something is really wrong");
|
throw new RuntimeException("Yeah... something is really wrong");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MinecraftProvider getMinecraftProvider() {
|
||||||
|
throw new RuntimeException("Yeah... something is really wrong");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ import net.fabricmc.loom.LoomGradleExtension;
|
||||||
import net.fabricmc.loom.configuration.InstallerData;
|
import net.fabricmc.loom.configuration.InstallerData;
|
||||||
import net.fabricmc.loom.configuration.LoomDependencyManager;
|
import net.fabricmc.loom.configuration.LoomDependencyManager;
|
||||||
import net.fabricmc.loom.configuration.processors.JarProcessorManager;
|
import net.fabricmc.loom.configuration.processors.JarProcessorManager;
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProviderImpl;
|
||||||
|
|
||||||
public class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl implements LoomGradleExtension {
|
public class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl implements LoomGradleExtension {
|
||||||
private final Project project;
|
private final Project project;
|
||||||
|
@ -110,6 +111,11 @@ public class LoomGradleExtensionImpl extends LoomGradleExtensionApiImpl implemen
|
||||||
return Objects.requireNonNull(jarProcessorManager, "Cannot get JarProcessorManager before it has been setup");
|
return Objects.requireNonNull(jarProcessorManager, "Cannot get JarProcessorManager before it has been setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MinecraftProviderImpl getMinecraftProvider() {
|
||||||
|
return getDependencyManager().getProvider(MinecraftProviderImpl.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MappingSet getOrCreateSrcMappingCache(int id, Supplier<MappingSet> factory) {
|
public MappingSet getOrCreateSrcMappingCache(int id, Supplier<MappingSet> factory) {
|
||||||
return srcMappingCache[id] != null ? srcMappingCache[id] : (srcMappingCache[id] = factory.get());
|
return srcMappingCache[id] != null ? srcMappingCache[id] : (srcMappingCache[id] = factory.get());
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
package net.fabricmc.loom.test.unit.layeredmappings
|
package net.fabricmc.loom.test.unit.layeredmappings
|
||||||
|
|
||||||
|
import net.fabricmc.loom.configuration.providers.MinecraftProvider
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder
|
import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder
|
||||||
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec
|
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec
|
||||||
|
@ -34,20 +35,41 @@ import org.gradle.util.ConfigureUtil
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
|
|
||||||
class LayeredMappingSpecBuilderTest extends Specification {
|
class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
|
MinecraftProvider mockMinecraftProvider = Mock(MinecraftProvider)
|
||||||
|
|
||||||
def "simple mojmap" () {
|
def "simple mojmap" () {
|
||||||
|
setup:
|
||||||
|
mockMinecraftProvider.minecraftVersion() >> "1.17"
|
||||||
when:
|
when:
|
||||||
def spec = layered() {
|
def spec = layered() {
|
||||||
officialMojangMappings()
|
officialMojangMappings()
|
||||||
}
|
}
|
||||||
def layers = spec.layers()
|
def layers = spec.layers()
|
||||||
then:
|
then:
|
||||||
spec.version == "layered+hash.961"
|
spec.version == "layered+hash.1506500"
|
||||||
|
layers.size() == 2
|
||||||
|
layers[0].class == IntermediaryMappingsSpec
|
||||||
|
layers[1].class == MojangMappingsSpec
|
||||||
|
}
|
||||||
|
|
||||||
|
def "simple mojmap alternative version" () {
|
||||||
|
setup:
|
||||||
|
mockMinecraftProvider.minecraftVersion() >> "1.17.1"
|
||||||
|
when:
|
||||||
|
def spec = layered() {
|
||||||
|
officialMojangMappings()
|
||||||
|
}
|
||||||
|
def layers = spec.layers()
|
||||||
|
then:
|
||||||
|
spec.version == "layered+hash.1446825415"
|
||||||
layers.size() == 2
|
layers.size() == 2
|
||||||
layers[0].class == IntermediaryMappingsSpec
|
layers[0].class == IntermediaryMappingsSpec
|
||||||
layers[1].class == MojangMappingsSpec
|
layers[1].class == MojangMappingsSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
def "simple mojmap with parchment" () {
|
def "simple mojmap with parchment" () {
|
||||||
|
setup:
|
||||||
|
mockMinecraftProvider.minecraftVersion() >> "1.17"
|
||||||
when:
|
when:
|
||||||
def spec = layered() {
|
def spec = layered() {
|
||||||
officialMojangMappings()
|
officialMojangMappings()
|
||||||
|
@ -56,7 +78,7 @@ class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
def layers = spec.layers()
|
def layers = spec.layers()
|
||||||
def parchment = layers[2] as ParchmentMappingsSpec
|
def parchment = layers[2] as ParchmentMappingsSpec
|
||||||
then:
|
then:
|
||||||
spec.version == "layered+hash.863714404"
|
spec.version == "layered+hash.910386113"
|
||||||
layers.size() == 3
|
layers.size() == 3
|
||||||
layers[0].class == IntermediaryMappingsSpec
|
layers[0].class == IntermediaryMappingsSpec
|
||||||
layers[1].class == MojangMappingsSpec
|
layers[1].class == MojangMappingsSpec
|
||||||
|
@ -66,6 +88,8 @@ class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
def "simple mojmap with parchment keep prefix" () {
|
def "simple mojmap with parchment keep prefix" () {
|
||||||
|
setup:
|
||||||
|
mockMinecraftProvider.minecraftVersion() >> "1.17"
|
||||||
when:
|
when:
|
||||||
def spec = layered() {
|
def spec = layered() {
|
||||||
officialMojangMappings()
|
officialMojangMappings()
|
||||||
|
@ -76,7 +100,7 @@ class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
def layers = spec.layers()
|
def layers = spec.layers()
|
||||||
def parchment = layers[2] as ParchmentMappingsSpec
|
def parchment = layers[2] as ParchmentMappingsSpec
|
||||||
then:
|
then:
|
||||||
spec.version == "layered+hash.863714410"
|
spec.version == "layered+hash.910386119"
|
||||||
layers.size() == 3
|
layers.size() == 3
|
||||||
layers[0].class == IntermediaryMappingsSpec
|
layers[0].class == IntermediaryMappingsSpec
|
||||||
layers[1].class == MojangMappingsSpec
|
layers[1].class == MojangMappingsSpec
|
||||||
|
@ -86,6 +110,8 @@ class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
def "simple mojmap with parchment keep prefix alternate hash" () {
|
def "simple mojmap with parchment keep prefix alternate hash" () {
|
||||||
|
setup:
|
||||||
|
mockMinecraftProvider.minecraftVersion() >> "1.17"
|
||||||
when:
|
when:
|
||||||
def spec = layered() {
|
def spec = layered() {
|
||||||
officialMojangMappings()
|
officialMojangMappings()
|
||||||
|
@ -96,7 +122,7 @@ class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
def layers = spec.layers()
|
def layers = spec.layers()
|
||||||
def parchment = layers[2] as ParchmentMappingsSpec
|
def parchment = layers[2] as ParchmentMappingsSpec
|
||||||
then:
|
then:
|
||||||
spec.version == "layered+hash.1144465487"
|
spec.version == "layered+hash.1097793778"
|
||||||
layers.size() == 3
|
layers.size() == 3
|
||||||
layers[0].class == IntermediaryMappingsSpec
|
layers[0].class == IntermediaryMappingsSpec
|
||||||
layers[1].class == MojangMappingsSpec
|
layers[1].class == MojangMappingsSpec
|
||||||
|
@ -111,7 +137,7 @@ class LayeredMappingSpecBuilderTest extends Specification {
|
||||||
}
|
}
|
||||||
|
|
||||||
LayeredMappingSpec layeredAction(Action<LayeredMappingSpecBuilder> action) {
|
LayeredMappingSpec layeredAction(Action<LayeredMappingSpecBuilder> action) {
|
||||||
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder()
|
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder(mockMinecraftProvider)
|
||||||
action.execute(builder)
|
action.execute(builder)
|
||||||
return builder.build()
|
return builder.build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ class MojangMappingLayerTest extends LayeredMappingsSpecification {
|
||||||
when:
|
when:
|
||||||
def mappings = getLayeredMappings(
|
def mappings = getLayeredMappings(
|
||||||
new IntermediaryMappingsSpec(),
|
new IntermediaryMappingsSpec(),
|
||||||
new MojangMappingsSpec()
|
new MojangMappingsSpec("1.17")
|
||||||
)
|
)
|
||||||
def tiny = getTiny(mappings)
|
def tiny = getTiny(mappings)
|
||||||
then:
|
then:
|
||||||
|
|
Loading…
Reference in New Issue