diff options
author | Shadowfacts <me@shadowfacts.net> | 2021-02-26 16:19:26 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-26 21:19:26 +0000 |
commit | 4540b3af33e80128c5e3e853640ec745dba85e32 (patch) | |
tree | 4850a5c965cc4cc9d457042feb2ba26f305f1fa4 /src/main/java/net/fabricmc/loom | |
parent | 57c9a8f3209121f22e84b8b01b64f1093256f1d3 (diff) | |
download | architectury-loom-4540b3af33e80128c5e3e853640ec745dba85e32.tar.gz architectury-loom-4540b3af33e80128c5e3e853640ec745dba85e32.tar.bz2 architectury-loom-4540b3af33e80128c5e3e853640ec745dba85e32.zip |
Add log4jConfigs to Loom extension (#356)
Allows mod build scripts to specify custom Log4j config files that will
be combined together when running Minecraft in the dev-env. For example:
loom {
log4jConfigs.from "MyCustomConfig.xml"
}
See: https://logging.apache.org/log4j/2.x/manual/configuration.html#CompositeConfiguration
Diffstat (limited to 'src/main/java/net/fabricmc/loom')
-rw-r--r-- | src/main/java/net/fabricmc/loom/LoomGradleExtension.java | 10 | ||||
-rw-r--r-- | src/main/java/net/fabricmc/loom/configuration/providers/LaunchProvider.java | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java index 1e03120e..ea089af0 100644 --- a/src/main/java/net/fabricmc/loom/LoomGradleExtension.java +++ b/src/main/java/net/fabricmc/loom/LoomGradleExtension.java @@ -66,6 +66,7 @@ public class LoomGradleExtension { public boolean shareCaches = false; private final ConfigurableFileCollection unmappedMods; + private final ConfigurableFileCollection log4jConfigs; final List<LoomDecompiler> decompilers = new ArrayList<>(); private final List<JarProcessor> jarProcessors = new ArrayList<>(); @@ -117,6 +118,7 @@ public class LoomGradleExtension { this.unmappedMods = project.files(); this.runConfigs = project.container(RunConfigSettings.class, baseName -> new RunConfigSettings(project, baseName)); + this.log4jConfigs = project.files(getDefaultLog4jConfigFile()); } /** @@ -348,6 +350,14 @@ public class LoomGradleExtension { return decompilers; } + public File getDefaultLog4jConfigFile() { + return new File(getProjectPersistentCache(), "log4j.xml"); + } + + public ConfigurableFileCollection getLog4jConfigs() { + return log4jConfigs; + } + @ApiStatus.Experimental public void runs(Action<NamedDomainObjectContainer<RunConfigSettings>> action) { action.execute(runConfigs); diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/LaunchProvider.java b/src/main/java/net/fabricmc/loom/configuration/providers/LaunchProvider.java index c0936217..f4511160 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/LaunchProvider.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/LaunchProvider.java @@ -59,7 +59,7 @@ public class LaunchProvider extends DependencyProvider { final LaunchConfig launchConfig = new LaunchConfig() .property("fabric.development", "true") .property("fabric.remapClasspathFile", getRemapClasspathFile().getAbsolutePath()) - .property("log4j.configurationFile", getLog4jConfigFile().getAbsolutePath()) + .property("log4j.configurationFile", getAllLog4JConfigFiles()) .property("client", "java.library.path", getExtension().getNativesDirectory().getAbsolutePath()) .property("client", "org.lwjgl.librarypath", getExtension().getNativesDirectory().getAbsolutePath()) @@ -87,7 +87,13 @@ public class LaunchProvider extends DependencyProvider { } private File getLog4jConfigFile() { - return new File(getExtension().getDevLauncherConfig().getParentFile(), "log4j.xml"); + return getExtension().getDefaultLog4jConfigFile(); + } + + private String getAllLog4JConfigFiles() { + return getExtension().getLog4jConfigs().getFiles().stream() + .map(File::getAbsolutePath) + .collect(Collectors.joining(",")); } private File getRemapClasspathFile() { |