Skip to content

Commit

Permalink
Better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Nov 15, 2024
1 parent 9d5cbf2 commit b3eb5bc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
14 changes: 12 additions & 2 deletions loader/src/main/java/net/neoforged/fml/loading/FMLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.slf4j.Logger;

public class FMLConfig {
Expand Down Expand Up @@ -146,12 +147,17 @@ public static void load() {
} else {
var removal = start == '-';
var depMod = str.substring(1);
LOGGER.warn("Found dependency override for mod '{}': {} '{}'", modId, removal ? "softening dependency constraints against" : "adding explicit AFTER ordering against", depMod);
overrides.add(new DependencyOverride(depMod, removal));
}
}
});
}

if (!DEPENDENCY_OVERRIDES.isEmpty()) {
LOGGER.warn("*".repeat(30) + " Found dependency overrides " + "*".repeat(30));
DEPENDENCY_OVERRIDES.forEach((modId, ov) -> LOGGER.warn("Dependency overrides for mod '{}': {}", modId, ov.stream().map(DependencyOverride::getMessage).collect(Collectors.joining(", "))));
LOGGER.warn("*".repeat(88));
}
}

public static String getConfigValue(ConfigValue v) {
Expand Down Expand Up @@ -191,5 +197,9 @@ public static Map<String, List<DependencyOverride>> getDependencyOverrides() {
return Collections.unmodifiableMap(DEPENDENCY_OVERRIDES);
}

public record DependencyOverride(String modId, boolean remove) {}
public record DependencyOverride(String modId, boolean remove) {
public String getMessage() {
return (remove ? "softening dependency constraints against" : "adding explicit AFTER ordering against") + " '" + modId + "'";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,9 @@ void testUnsatisfiedNeoForgeRange() throws Exception {
@Test
void testDependencyOverride() throws Exception {
installation.setupProductionClient();
installation.appendToConfig("dependencyOverrides.targetmod = [\"-depmod\"]");
installation.buildModJar("depmod.jar")
.withModsToml(builder -> {
builder.unlicensedJavaMod();
builder.addMod("depmod", "1.0");
});
installation.appendToConfig("dependencyOverrides.targetmod = [\"-depmod\", \"-incompatiblemod\"]");
installation.buildModJar("depmod.jar").withMod("depmod", "1.0");
installation.buildModJar("incompatiblemod.jar").withMod("incompatiblemod", "1.0");
installation.buildModJar("targetmod.jar")
.withModsToml(builder -> {
builder.unlicensedJavaMod();
Expand All @@ -412,7 +409,12 @@ void testDependencyOverride() throws Exception {
sub.set("modId", "depmod");
sub.set("versionRange", "[2,)");
sub.set("type", "required");
c.set("dependencies.targetmod", new ArrayList<>(Arrays.asList(sub)));

var sub2 = Config.inMemory();
sub2.set("modId", "incompatiblemod");
sub2.set("versionRange", "[1,");
sub2.set("type", "incompatible");
c.set("dependencies.targetmod", new ArrayList<>(Arrays.asList(sub, sub2)));
});
});
assertThat(launchAndLoad("forgeclient").issues()).isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public ModFileBuilder withTestmodModsToml(Consumer<ModsTomlBuilder> customizer)
});
}

public ModFileBuilder withMod(String id, String version) {
return withModsToml(builder -> builder.unlicensedJavaMod().addMod(id, version));
}

public ModFileBuilder withModTypeManifest(IModFile.Type type) {
return withManifest(Map.of(
"FMLModType", type.name()));
Expand Down

0 comments on commit b3eb5bc

Please sign in to comment.