downloadMavenSources static method
Downloads and unpacks source files of deps
into targetDir
.
Implementation
static Future<void> downloadMavenSources(
List<MavenDependency> deps, String targetDir) async {
for (var i = 0; i < deps.length; i++) {
final sourceJarLocation = deps[i].toURLString(repoLocation);
await File(join(targetDir, deps[i].filename()))
.writeAsBytes(await http.readBytes(Uri.parse(sourceJarLocation)));
}
// Use gradle to extract the source jars.
// This flow is needed because Gradle
// defaults to compiled jars where available.
final tempDir = await currentDir.createTemp('maven_temp_');
await _runGradleCommand(deps, extractSources: true, targetDir);
await tempDir.delete(recursive: true);
}