Skip to content

Commit

Permalink
Use redirect file for help:evaluate (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtnord authored Mar 1, 2023
1 parent d384542 commit 7c2ed47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jenkins/tools/test/PluginCompatTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,9 @@ public static String getMavenModule(String plugin, File pluginPath, MavenRunner
}
File log = new File(parentFile.getAbsolutePath() + File.separatorChar + "modules.log");
runner.run(
Map.of("expression", "project.modules", "forceStdout", "true"),
Map.of("expression", "project.modules", "output", log.getAbsolutePath()),
parentFile,
log,
null,
"-q",
"help:evaluate");
List<String> lines;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ private boolean isSnapshotMultiParentPlugin(

File log = new File(parentFile.getAbsolutePath() + File.separatorChar + "version.log");
runner.run(
Map.of("expression", "project.version", "forceStdout", "true"),
Map.of("expression", "project.version", "output", log.getAbsolutePath()),
parentFile,
log,
null,
"-q",
"help:evaluate");
List<String> output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -107,9 +108,9 @@ private static class MavenGobbler extends Thread {

@NonNull private final Process p;

@NonNull private final File buildLogFile;
@CheckForNull private final File buildLogFile;

public MavenGobbler(@NonNull Process p, @NonNull File buildLogFile) {
public MavenGobbler(@NonNull Process p, @Nullable File buildLogFile) {
this.p = p;
this.buildLogFile = buildLogFile;
}
Expand All @@ -119,7 +120,10 @@ public void run() {
try (InputStream is = p.getInputStream();
Reader isr = new InputStreamReader(is, Charset.defaultCharset());
BufferedReader r = new BufferedReader(isr);
OutputStream os = new FileOutputStream(buildLogFile, true);
OutputStream os =
buildLogFile == null
? OutputStream.nullOutputStream()
: new FileOutputStream(buildLogFile, true);
Writer osw = new OutputStreamWriter(os, Charset.defaultCharset());
PrintWriter w = new PrintWriter(osw)) {
String line;
Expand Down

0 comments on commit 7c2ed47

Please sign in to comment.