|
4 | 4 | import java.io.IOException; |
5 | 5 | import java.nio.charset.StandardCharsets; |
6 | 6 | import java.nio.file.Files; |
| 7 | +import java.nio.file.StandardCopyOption; |
7 | 8 | import java.util.ArrayList; |
8 | 9 | import java.util.LinkedHashMap; |
9 | 10 | import java.util.List; |
@@ -55,6 +56,17 @@ abstract class PrepareRunOrTest extends DefaultTask { |
55 | 56 | @OutputFile |
56 | 57 | public abstract RegularFileProperty getProgramArgsFile(); |
57 | 58 |
|
| 59 | + /** |
| 60 | + * A file to use for the {@code log4j2.xml} config file that will be written. |
| 61 | + * If absent, the standard log4j2.xml file produced by {@link RunUtils#writeLog4j2Configuration} will be used. |
| 62 | + */ |
| 63 | + @InputFile |
| 64 | + @Optional |
| 65 | + public abstract RegularFileProperty getLog4jConfigFileOverride(); |
| 66 | + |
| 67 | + /** |
| 68 | + * Where the {@code log4j2.xml} config file will be written. |
| 69 | + */ |
58 | 70 | @OutputFile |
59 | 71 | @Optional |
60 | 72 | public abstract RegularFileProperty getLog4jConfigFile(); |
@@ -239,7 +251,11 @@ private void writeJvmArguments(UserDevRunType runConfig, Map<String, String> add |
239 | 251 |
|
240 | 252 | if (getLog4jConfigFile().isPresent()) { |
241 | 253 | var log4jConfigFile = getLog4jConfigFile().get().getAsFile(); |
242 | | - RunUtils.writeLog4j2Configuration(getGameLogLevel().get(), log4jConfigFile.toPath()); |
| 254 | + if (getLog4jConfigFileOverride().isPresent()) { |
| 255 | + Files.copy(getLog4jConfigFileOverride().get().getAsFile().toPath(), log4jConfigFile.toPath(), StandardCopyOption.REPLACE_EXISTING); |
| 256 | + } else { |
| 257 | + RunUtils.writeLog4j2Configuration(getGameLogLevel().get(), log4jConfigFile.toPath()); |
| 258 | + } |
243 | 259 | lines.add(RunUtils.escapeJvmArg("-Dlog4j2.configurationFile=" + log4jConfigFile.getAbsolutePath())); |
244 | 260 | } |
245 | 261 |
|
|
0 commit comments