runProvisioningCli function
A complete setup_jars command for spec, returning the exit code:
0 ok, 1 usage, 2 Maven not found or not runnable, 3 the runtime
could not be provisioned (Maven failed, the cache is not writable) or,
for --verify-only and --print-classpath, is not there, 4
verification failed. Output is flushed before it returns.
A package's whole bin/setup_jars.dart can be:
import 'dart:io';
import 'package:java_interop/provisioning.dart';
import 'package:my_reports/src/java_runtime.dart';
Future<void> main(List<String> args) async =>
exit(await runProvisioningCli(reportsRuntime, args));
Options: --cache-dir <dir>, --maven <path>, --offline, --force,
--verify-only, --print-classpath, -h/--help.
Implementation
Future<int> runProvisioningCli(
JavaRuntimeSpec spec,
List<String> args, {
IOSink? out,
IOSink? err,
Map<String, String>? environment,
}) async {
final stdoutSink = out ?? stdout;
final stderrSink = err ?? stderr;
try {
return await _cli(spec, args, stdoutSink, stderrSink, environment);
} finally {
// `exit` right after does not wait for buffered output: a piped
// `--print-classpath` would come out cut.
await stdoutSink.flush();
await stderrSink.flush();
}
}