buildApiSummarizer function

Future<void> buildApiSummarizer()

Implementation

Future<void> buildApiSummarizer() async {
  final pkg = await findPackageRoot('jnigen');
  if (pkg == null) {
    log.fatal('package jnigen not found!');
  }
  final pom = pkg.resolve('java/pom.xml');
  await Directory(toolPath).create(recursive: true);
  final mvnArgs = [
    'compile',
    '--batch-mode',
    '--update-snapshots',
    '-f',
    pom.toFilePath(),
  ];
  log.info('execute mvn ${mvnArgs.join(" ")}');
  try {
    final mvnProc = await Process.run('mvn', mvnArgs,
        workingDirectory: toolPath, runInShell: true);
    final exitCode = mvnProc.exitCode;
    if (exitCode == 0) {
      await File(targetJarFile).rename(jarFile);
    } else {
      printError(mvnProc.stdout);
      printError(mvnProc.stderr);
      printError('maven exited with $exitCode');
    }
  } finally {
    await Directory(mvnTargetDir).delete(recursive: true);
  }
}