Skip to content

Commit

Permalink
Merge pull request #371 from ascopes/task/log-generated-scripts
Browse files Browse the repository at this point in the history
Log generated scripts in debug logs
  • Loading branch information
ascopes authored Sep 14, 2024
2 parents e80f80c + 83b464e commit fc21a23
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -250,7 +251,7 @@ private Path writeWindowsBatchScript(
"" // Trailing newline.
);

Files.writeString(fullScriptPath, script, StandardCharsets.ISO_8859_1);
writeScript(fullScriptPath, script, StandardCharsets.ISO_8859_1);
return fullScriptPath;
}

Expand All @@ -277,11 +278,16 @@ private Path writeShellScript(
"" // Trailing newline
);

Files.writeString(fullScriptPath, script, StandardCharsets.UTF_8);
FileUtils.makeExecutable(fullScriptPath);
writeScript(fullScriptPath, script, StandardCharsets.UTF_8);
return fullScriptPath;
}

private void writeScript(Path path, String content, Charset charset) throws IOException {
log.debug("Writing the following script to {} as {}:\n{}", path, charset, content);
Files.writeString(path, content, charset);
FileUtils.makeExecutable(path);
}

private List<Path> findJavaModules(List<Path> paths) {
// TODO: is using a module finder here an overkill?
return ModuleFinder.of(paths.toArray(Path[]::new))
Expand Down

0 comments on commit fc21a23

Please sign in to comment.