From 6610b7ea040fba97559ee195d7fc8a7919f9e438 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Mon, 25 Jan 2016 15:05:06 -0500 Subject: [PATCH] Support local paths to third-party jars in flutter apk. Also improve the error message a bit if a download fails. --- packages/flutter_tools/lib/src/artifacts.dart | 7 ++++--- packages/flutter_tools/lib/src/commands/apk.dart | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 04b0d491fd2..dfc16c864a4 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -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); } } diff --git a/packages/flutter_tools/lib/src/commands/apk.dart b/packages/flutter_tools/lib/src/commands/apk.dart index b6f8e533173..b5e5c6078d8 100644 --- a/packages/flutter_tools/lib/src/commands/apk.dart +++ b/packages/flutter_tools/lib/src/commands/apk.dart @@ -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))); } } }