downloadMavenSources static method

Future<void> downloadMavenSources(
  1. List<MavenDependency> deps,
  2. String targetDir
)

Downloads and unpacks source files of deps into targetDir.

Implementation

static Future<void> downloadMavenSources(
    List<MavenDependency> deps, String targetDir) async {
  // TODO(https://github.com/dart-lang/native/issues/2579): Make this use
  // gradle as well, instead of manually downloading deps via http.
  for (final dep in deps) {
    final targetFile = File(join(targetDir, dep.filename()));
    await targetFile.parent.create(recursive: true);
    final sourceJarLocation = dep.toURLString(repoLocation);
    await targetFile
        .writeAsBytes(await http.readBytes(Uri.parse(sourceJarLocation)));
  }
  await _runGradleCommand(deps, extractSources: true, targetDir);
}