Support local paths to third-party jars in flutter apk.

Also improve the error message a bit if a download fails.
This commit is contained in:
Matt Perry 2016-01-25 15:05:06 -05:00
parent dc74fe3d6c
commit 6610b7ea04
2 changed files with 8 additions and 6 deletions

View File

@ -328,9 +328,10 @@ class ArtifactStore {
File cachedFile = new File(
path.join(cacheDir.path, url.pathSegments[url.pathSegments.length-1]));
if (!cachedFile.existsSync()) {
await _downloadFileToCache(url, cachedFile);
if (!cachedFile.existsSync()) {
logging.severe('Unable to fetch third-party artifact: $url');
try {
await _downloadFileToCache(url, cachedFile);
} catch (e) {
logging.severe('Failed to fetch third-party artifact: $url: $e');
throw new ProcessExit(2);
}
}

View File

@ -194,16 +194,17 @@ class ApkCommand extends FlutterCommand {
continue;
components.services.addAll(serviceConfig['services']);
for (String jar in serviceConfig['jars']) {
// Jar might refer to an android SDK jar, or URL to download.
if (jar.startsWith("android-sdk:")) {
// Jar is something shipped in the standard android SDK.
jar = jar.replaceAll('android-sdk:', '${components.androidSdk.path}/');
components.jars.add(new File(jar));
} else if (jar.startsWith("http")) {
// Jar is a URL to download.
String cachePath = await ArtifactStore.getThirdPartyFile(jar, service);
components.jars.add(new File(cachePath));
} else {
logging.severe('Service depends on a jar in an unrecognized format: $jar');
throw new ProcessExit(2);
// Assume jar is a path relative to the service's root dir.
components.jars.add(new File(path.join(serviceRoot, jar)));
}
}
}