diff options
author | Adam Michael <ajmichael@bazel.build> | 2017-02-21 20:42:58 +0000 |
---|---|---|
committer | Irina Iancu <elenairina@google.com> | 2017-02-22 08:27:29 +0000 |
commit | cf9a2b662b2764fd3bddcb74d9a0ab70eb2f7f3d (patch) | |
tree | 7d4f3334d8395c9e8a1fb5626894bc4c0171700e /src/main/java/com | |
parent | 17db60ea7d9479975b263282004bcbfc8a0138e2 (diff) |
Rollback of commit e49886c55a7e2cfd6dd1fc52b037dc2d5a6ca019.
*** Reason for rollback ***
Rollforward with fix for android_integration_test.sh. android_integration_test.sh should no longer make assumptions about the SDK api_level that is installed.
Note that it does still assume NDK api_level 24 and support libraries 24.0.0 and android_sdk_repository itself requires build_tools_version >= 24.0.3. I will try and loosen the first two of those dependencies of this test at some point.
--
PiperOrigin-RevId: 148130764
MOS_MIGRATED_REVID=148130764
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java index ebee8e33f7..7a4968dae3 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryFunction.java @@ -123,17 +123,31 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { Transience.PERSISTENT); } - String defaultApiLevel; + Integer defaultApiLevel; if (attributes.isAttributeValueExplicitlySpecified("api_level")) { try { - defaultApiLevel = attributes.get("api_level", Type.INTEGER).toString(); + defaultApiLevel = attributes.get("api_level", Type.INTEGER); } catch (EvalException e) { throw new RepositoryFunctionException(e, Transience.PERSISTENT); } + if (!apiLevels.contains(defaultApiLevel)) { + throw new RepositoryFunctionException( + new EvalException( + rule.getLocation(), + String.format( + "Android SDK api level %s was requested but it is not installed in the Android " + + "SDK at %s. The api levels found were %s. Please choose an available api " + + "level or install api level %s from the Android SDK Manager.", + defaultApiLevel, + androidSdkPath, + apiLevels.toString(), + defaultApiLevel)), + Transience.PERSISTENT); + } } else { // If the api_level attribute is not explicitly set, we select the highest api level that is // available in the SDK. - defaultApiLevel = String.valueOf(apiLevels.first()); + defaultApiLevel = apiLevels.first(); } String buildToolsDirectory; @@ -198,7 +212,7 @@ public class AndroidSdkRepositoryFunction extends RepositoryFunction { .replace("%build_tools_version%", buildToolsVersion) .replace("%build_tools_directory%", buildToolsDirectory) .replace("%api_levels%", Iterables.toString(apiLevels)) - .replace("%default_api_level%", defaultApiLevel) + .replace("%default_api_level%", String.valueOf(defaultApiLevel)) .replace("%system_image_dirs%", systemImageDirsList); // All local maven repositories that are shipped in the Android SDK. |