Skip to content

Commit

Permalink
Write raw javac output to a log file
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Nov 4, 2024
1 parent 39e5a13 commit a856c4e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Deque;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -545,6 +550,14 @@ protected CompilerResult compileOutOfProcess(CompilerConfiguration config, Strin
try {
returnCode = CommandLineUtils.executeCommandLine(cli, out, out);

Path logsDir = config.getBuildDirectory().toPath().resolve("compiler-logs");
if (!Files.exists(logsDir)) {
Files.createDirectories(logsDir);
}
SimpleDateFormat dateFormat = new SimpleDateFormat("'javac'_yyyy-MM-dd'T'HH_mm_ss.'log'");
String logFileName = dateFormat.format(new Date());
Files.write(logsDir.resolve(logFileName), out.getOutput().getBytes(StandardCharsets.UTF_8));

messages = parseModernStream(returnCode, new BufferedReader(new StringReader(out.getOutput())));
} catch (CommandLineException | IOException e) {
throw new CompilerException("Error while executing the external compiler.", e);
Expand Down

0 comments on commit a856c4e

Please sign in to comment.