2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-26 08:37:11 -07:00

Don't try to avoid other std output when help is generating JSON, the plugin will now parse the JSON out regardless

This commit is contained in:
Geert Bevin 2024-07-20 15:06:29 -04:00
parent 3ec2cc68ce
commit 0e4e171a81
2 changed files with 7 additions and 30 deletions

Binary file not shown.

View file

@ -35,14 +35,11 @@ import static rife.tools.FileUtils.JAVA_FILE_PATTERN;
public class Wrapper { public class Wrapper {
private enum LaunchMode { private enum LaunchMode {
Cli, Cli,
Build, Build
Json
} }
public static final String BUILD_ARGUMENT = "--build"; public static final String BUILD_ARGUMENT = "--build";
public static final String JSON_ARGUMENT = "--json";
public static final String OFFLINE_ARGUMENT = "--offline"; public static final String OFFLINE_ARGUMENT = "--offline";
public static final String HELP_COMMAND = "help";
public static final String WRAPPER_PREFIX = "bld-wrapper"; public static final String WRAPPER_PREFIX = "bld-wrapper";
public static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties"; public static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties";
@ -399,18 +396,6 @@ public class Wrapper {
OFFLINE_ARGUMENT.equals(arguments.get(1))) { OFFLINE_ARGUMENT.equals(arguments.get(1))) {
offline_ = true; offline_ = true;
} }
var help_index = arguments.indexOf(HELP_COMMAND);
if (help_index != -1) {
try {
if (arguments.get(help_index + 1).equals(JSON_ARGUMENT) ||
arguments.get(help_index + 2).equals(JSON_ARGUMENT)) {
launchMode_ = LaunchMode.Json;
}
} catch (IndexOutOfBoundsException e) {
// no-op, there are no additional arguments, so definitely no json option
}
}
} }
try { try {
@ -520,10 +505,8 @@ public class Wrapper {
var is_snapshot = isSnapshot(version); var is_snapshot = isSnapshot(version);
var is_local = false; var is_local = false;
if (offline_) { if (offline_) {
if (launchMode_ != LaunchMode.Json) { System.out.println("Offline mode: no artifacts will be checked nor downloaded");
System.out.println("Offline mode: no artifacts will be checked nor downloaded"); System.out.flush();
System.out.flush();
}
} }
else { else {
if (is_snapshot) { if (is_snapshot) {
@ -600,19 +583,15 @@ public class Wrapper {
private void downloadDistribution(File file, String downloadUrl) private void downloadDistribution(File file, String downloadUrl)
throws IOException { throws IOException {
try { try {
if (launchMode_ != LaunchMode.Json) { System.out.print("Downloading: " + downloadUrl + " ... ");
System.out.print("Downloading: " + downloadUrl + " ... "); System.out.flush();
System.out.flush();
}
var url = new URL(downloadUrl); var url = new URL(downloadUrl);
var readableByteChannel = Channels.newChannel(url.openStream()); var readableByteChannel = Channels.newChannel(url.openStream());
try (var fileOutputStream = new FileOutputStream(file)) { try (var fileOutputStream = new FileOutputStream(file)) {
var fileChannel = fileOutputStream.getChannel(); var fileChannel = fileOutputStream.getChannel();
fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE); fileChannel.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
if (launchMode_ != LaunchMode.Json) { System.out.print("done");
System.out.print("done");
}
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.err.println("not found"); System.err.println("not found");
@ -624,9 +603,7 @@ public class Wrapper {
Files.deleteIfExists(file.toPath()); Files.deleteIfExists(file.toPath());
throw e; throw e;
} finally { } finally {
if (launchMode_ != LaunchMode.Json) { System.out.println();
System.out.println();
}
} }
} }