in src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java [1663:1715]
private void writeDebugFile(final ToolExecutor executor, final Options configuration) throws IOException {
final Path path = getDebugFilePath();
if (path == null) {
logger.warn("The <debugFileName> parameter should not be empty.");
return;
}
final var commandLine = new StringBuilder("For trying to compile from the command-line, use:");
final var chdir =
Path.of(System.getProperty("user.dir")).relativize(basedir).toString();
if (!chdir.isEmpty()) {
boolean isWindows = (File.separatorChar == '\\');
commandLine
.append(System.lineSeparator())
.append(" ")
.append(isWindows ? "chdir " : "cd ")
.append(chdir);
}
commandLine.append(System.lineSeparator()).append(" ").append(executable != null ? executable : compilerId);
try (BufferedWriter out = Files.newBufferedWriter(path)) {
configuration.format(commandLine, out);
for (Map.Entry<PathType, List<Path>> entry : executor.dependencies.entrySet()) {
List<Path> files = entry.getValue();
files = files.stream().map(this::relativize).toList();
String separator = "";
for (String element : entry.getKey().option(files)) {
out.write(separator);
out.write(element);
separator = " ";
}
out.newLine();
}
out.write("-d \"");
out.write(relativize(getOutputDirectory()).toString());
out.write('"');
out.newLine();
try {
executor.getSourceFiles().forEach((file) -> {
try {
out.write('"');
out.write(relativize(file).toString());
out.write('"');
out.newLine();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
} catch (UncheckedIOException e) {
throw e.getCause();
}
}
tipForCommandLineCompilation =
commandLine.append(" @").append(relativize(path)).toString();
}