mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Fix codestyle, add forge tests
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -32,7 +32,6 @@ import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import dev.architectury.tinyremapper.TinyRemapper;
|
||||
import org.gradle.api.Project;
|
||||
import org.objectweb.asm.commons.Remapper;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
@@ -44,9 +43,6 @@ import net.fabricmc.accesswidener.AccessWidenerWriter;
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.configuration.processors.JarProcessor;
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMappedProvider;
|
||||
import net.fabricmc.loom.util.Checksum;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
|
||||
public class AccessWidenerJarProcessor implements JarProcessor {
|
||||
// Filename used to store hash of input access widener in processed jar file
|
||||
|
||||
@@ -162,14 +162,20 @@ public class ForgeUserdevProvider extends DependencyProvider {
|
||||
if (settings != null) {
|
||||
settings.evaluateLater(() -> {
|
||||
settings.defaultMainClass(value.getAsJsonPrimitive("main").getAsString());
|
||||
settings.vmArgs(StreamSupport.stream(value.getAsJsonArray("jvmArgs").spliterator(), false)
|
||||
.map(JsonElement::getAsString)
|
||||
.map(this::processTemplates)
|
||||
.collect(Collectors.toList()));
|
||||
for (Map.Entry<String, JsonElement> env : value.getAsJsonObject("env").entrySet()) {
|
||||
String string = processTemplates(env.getValue().getAsString());
|
||||
|
||||
settings.envVariables.put(env.getKey(), string);
|
||||
if (value.has("jvmArgs")) {
|
||||
settings.vmArgs(StreamSupport.stream(value.getAsJsonArray("jvmArgs").spliterator(), false)
|
||||
.map(JsonElement::getAsString)
|
||||
.map(this::processTemplates)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
if (value.has("env")) {
|
||||
for (Map.Entry<String, JsonElement> env : value.getAsJsonObject("env").entrySet()) {
|
||||
String string = processTemplates(env.getValue().getAsString());
|
||||
|
||||
settings.envVariables.put(env.getKey(), string);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ public class MinecraftPatchedProvider extends DependencyProvider {
|
||||
}
|
||||
}
|
||||
|
||||
Files.writeString(outTrimmed, Tsrg2Writer.serialize(tree), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
Files.writeString(outTrimmed, Tsrg2Writer.serialize(tree), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
|
||||
mergedMojangTsrg2Files = new Path[]{out, outTrimmed};
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ public class MappingsProviderImpl extends DependencyProvider implements Mappings
|
||||
MappingsNamespace.INTERMEDIARY.toString(), MappingsNamespace.OFFICIAL.toString());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not merge mappings from " + intermediaryMappings.toString()
|
||||
+ " with mappings from " + yarnMappings, e);
|
||||
+ " with mappings from " + yarnMappings, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.gradle.api.Project;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import net.fabricmc.loom.LoomGradleExtension;
|
||||
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
|
||||
import net.fabricmc.loom.configuration.RemappedConfigurationEntry;
|
||||
import net.fabricmc.loom.configuration.providers.mappings.MappingsProviderImpl;
|
||||
import net.fabricmc.loom.util.gradle.ProgressLogger;
|
||||
|
||||
@@ -54,6 +54,7 @@ public class SpecialSourceExecutor {
|
||||
} else if (string.startsWith("/")) {
|
||||
return string.substring(1);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -78,10 +79,12 @@ public class SpecialSourceExecutor {
|
||||
if (!trimLeadingSlash.endsWith(".class")) continue;
|
||||
boolean has = filter.contains(trimLeadingSlash);
|
||||
String s = trimLeadingSlash;
|
||||
|
||||
while (s.contains("$") && !has) {
|
||||
s = s.substring(0, s.lastIndexOf("$")) + ".class";
|
||||
has = filter.contains(s);
|
||||
}
|
||||
|
||||
if (!has) continue;
|
||||
Path to = output.get().getPath(trimLeadingSlash);
|
||||
Path parent = to.getParent();
|
||||
@@ -123,7 +126,7 @@ public class SpecialSourceExecutor {
|
||||
|
||||
// if running with INFO or DEBUG logging
|
||||
if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS
|
||||
|| project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) {
|
||||
|| project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) {
|
||||
spec.setStandardOutput(System.out);
|
||||
spec.setErrorOutput(System.err);
|
||||
} else {
|
||||
@@ -161,7 +164,7 @@ public class SpecialSourceExecutor {
|
||||
|
||||
// if running with INFO or DEBUG logging
|
||||
if (project.getGradle().getStartParameter().getShowStacktrace() != ShowStacktrace.INTERNAL_EXCEPTIONS
|
||||
|| project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) {
|
||||
|| project.getGradle().getStartParameter().getLogLevel().compareTo(LogLevel.LIFECYCLE) < 0) {
|
||||
spec.setStandardOutput(System.out);
|
||||
spec.setErrorOutput(System.err);
|
||||
} else {
|
||||
|
||||
@@ -37,6 +37,7 @@ public class Tsrg2Writer {
|
||||
|
||||
private static void writeMethod(List<String> namespaces, MappingTree.MethodMapping def, StringBuilder builder) {
|
||||
writeMapped(true, namespaces, def, builder);
|
||||
|
||||
for (MappingTree.MethodArgMapping arg : def.getArgs()) {
|
||||
builder.append("\t\t").append(arg.getLvIndex());
|
||||
writeMapped(true, namespaces, arg, builder);
|
||||
@@ -52,6 +53,7 @@ public class Tsrg2Writer {
|
||||
|
||||
for (int i = 0; i < names.length; ++i) {
|
||||
String name = names[i];
|
||||
|
||||
if (i == 0) {
|
||||
if (needFirst) {
|
||||
builder.append('\t');
|
||||
@@ -61,8 +63,10 @@ public class Tsrg2Writer {
|
||||
}
|
||||
|
||||
builder.append(name);
|
||||
|
||||
if (i == 0 && mapped instanceof MappingTreeView.MemberMappingView) {
|
||||
String descriptor = ((MappingTreeView.MemberMappingView) mapped).getSrcDesc();
|
||||
|
||||
if (descriptor != null && !descriptor.isEmpty()) {
|
||||
builder.append(' ');
|
||||
builder.append(descriptor);
|
||||
|
||||
Reference in New Issue
Block a user