Readd silenceLicense

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel
2021-06-20 02:26:17 +08:00
parent 4b1f5cc127
commit 10d810fad1
6 changed files with 28 additions and 7 deletions

View File

@@ -227,7 +227,7 @@ public class LoomGradleExtension {
}
public Dependency layered(Action<LayeredMappingSpecBuilder> action) {
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder();
LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder(this);
action.execute(builder);
LayeredMappingSpec builtSpec = builder.build();
return new LayeredMappingsDependency(new GradleMappingContext(project, "layers_" + builtSpec.getVersion().replace("+", "_").replace(".", "_")), builtSpec, builtSpec.getVersion());

View File

@@ -67,6 +67,7 @@ public class LoomGradlePlugin implements BootstrappedPlugin {
loggedVersions.add(loomVersion);
System.setProperty("loom.printed.logged", String.join(",", loggedVersions));
project.getLogger().lifecycle("Architectury Loom: " + loomVersion);
project.getLogger().lifecycle("You are using an unstable version of Architectury Loom! Please report any issues found!");
}
refreshDeps = project.getGradle().getStartParameter().isRefreshDependencies() || "true".equals(System.getProperty("loom.refresh"));

View File

@@ -29,16 +29,24 @@ import java.util.LinkedList;
import java.util.List;
import org.gradle.api.Action;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.loom.LoomGradleExtension;
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.parchment.ParchmentMappingsSpecBuilder;
public class LayeredMappingSpecBuilder {
private final List<MappingsSpec<?>> layers = new LinkedList<>();
@Nullable
private final LoomGradleExtension extension;
public LayeredMappingSpecBuilder(LoomGradleExtension extension) {
this.extension = extension;
}
public LayeredMappingSpecBuilder officalMojangMappings() {
layers.add(new MojangMappingsSpec());
layers.add(new MojangMappingsSpec(() -> extension != null && extension.isSilentMojangMappingsLicenseEnabled()));
return this;
}

View File

@@ -32,6 +32,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.function.BooleanSupplier;
import org.gradle.api.logging.Logger;
@@ -47,7 +48,8 @@ import net.fabricmc.mappingio.format.ProGuardReader;
public record MojangMappingLayer(MinecraftVersionMeta.Download clientDownload,
MinecraftVersionMeta.Download serverDownload,
File workingDir,
Logger logger) implements MappingLayer {
Logger logger,
BooleanSupplier silenceLicense) implements MappingLayer {
@Override
public void visit(MappingVisitor mappingVisitor) throws IOException {
var clientMappings = new File(workingDir(), "client.txt");
@@ -55,7 +57,9 @@ public record MojangMappingLayer(MinecraftVersionMeta.Download clientDownload,
download(clientMappings, serverMappings);
printMappingsLicense(clientMappings.toPath());
if (!silenceLicense.getAsBoolean()) {
printMappingsLicense(clientMappings.toPath());
}
// Make official the source namespace
MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(mappingVisitor, MappingNamespace.OFFICIAL.stringValue());

View File

@@ -24,15 +24,21 @@
package net.fabricmc.loom.configuration.providers.mappings.mojmap;
import java.util.function.BooleanSupplier;
import net.fabricmc.loom.configuration.providers.mappings.MappingContext;
import net.fabricmc.loom.configuration.providers.mappings.MappingsSpec;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
public record MojangMappingsSpec() implements MappingsSpec<MojangMappingLayer> {
public record MojangMappingsSpec(BooleanSupplier silenceLicense) implements MappingsSpec<MojangMappingLayer> {
// Keys in dependency manifest
private static final String MANIFEST_CLIENT_MAPPINGS = "client_mappings";
private static final String MANIFEST_SERVER_MAPPINGS = "server_mappings";
public MojangMappingsSpec() {
this(() -> false);
}
@Override
public MojangMappingLayer createLayer(MappingContext context) {
MinecraftVersionMeta versionInfo = context.minecraftProvider().getVersionInfo();
@@ -45,7 +51,8 @@ public record MojangMappingsSpec() implements MappingsSpec<MojangMappingLayer> {
versionInfo.download(MANIFEST_CLIENT_MAPPINGS),
versionInfo.download(MANIFEST_SERVER_MAPPINGS),
context.workingDirectory("mojang"),
context.getLogger()
context.getLogger(),
silenceLicense()
);
}
}