Skip to content

Commit

Permalink
Improve variable naming, address Checkstyle warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes committed Sep 23, 2024
1 parent 197ac56 commit bc59f5b
Showing 1 changed file with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,27 @@ private Path writePosixScripts(
ArgumentFileBuilder argFileBuilder
) throws IOException, ResolutionException {
var sh = pathResolver.resolve("sh").orElseThrow();
var content = writeArgLineFile(id, StandardCharsets.UTF_8, scratchDir, argFileBuilder);
var file = scratchDir.resolve("invoke.sh");
var argFile = writeArgFile(id, StandardCharsets.UTF_8, scratchDir, argFileBuilder);

var sb = new StringBuilder()
var script = new StringBuilder()
.append("#!").append(sh).append('\n')
.append("set -o errexit\n")
.append("set -o posix > /dev/null 2>&1 || :\n");

quoteShellArg(sb, javaExecutable.toString());
quoteShellArg(script, javaExecutable.toString());
sb.append(' ');
quoteShellArg(sb, "@" + content);
quoteShellArg(script, "@" + argFile);
sb.append('\n');

Files.writeString(file, sb, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW);
FileUtils.makeExecutable(file);
return file;
var scriptFile = scratchDir.resolve("invoke.sh");
Files.writeString(
scriptFile,
script,
StandardCharsets.UTF_8,
StandardOpenOption.CREATE_NEW
);
FileUtils.makeExecutable(script);
return scriptFile;
}

private Path writeWindowsScripts(
Expand All @@ -321,18 +326,23 @@ private Path writeWindowsScripts(
Path scratchDir,
ArgumentFileBuilder argFileBuilder
) throws IOException {
var content = writeArgLineFile(id, StandardCharsets.ISO_8859_1, scratchDir, argFileBuilder);
var file = scratchDir.resolve("invoke.bat");
var argFile = writeArgFile(id, StandardCharsets.ISO_8859_1, scratchDir, argFileBuilder);

var sb = new StringBuilder()
var script = new StringBuilder()
.append("@echo off\r\n");

quoteBatchArg(sb, javaExecutable.toString());
quoteBatchArg(script, javaExecutable.toString());
sb.append(' ');
quoteBatchArg(sb, "@" + content);
quoteBatchArg(script, "@" + argFile);
sb.append("\r\n");

Files.writeString(file, sb, StandardCharsets.ISO_8859_1, StandardOpenOption.CREATE_NEW);
var scriptFile = scratchDir.resolve("invoke.bat");
Files.writeString(
scriptFile,
script,
StandardCharsets.ISO_8859_1,
StandardOpenOption.CREATE_NEW
);
return file;
}

Expand Down

0 comments on commit bc59f5b

Please sign in to comment.