Remove BUILD.glob and incorporate the necessary filegroups into the android_{ndk,sdk}_repository rules themselves.

This is to that the Android tests also work on OS X (otherwise, we'd end up creating a file called "BUILD" in its root, which doesn't work, because it already has a directory called "build")

--
MOS_MIGRATED_REVID=102484286
diff --git a/BUILD.glob b/BUILD.glob
deleted file mode 100644
index aeb4008..0000000
--- a/BUILD.glob
+++ /dev/null
@@ -1 +0,0 @@
-filegroup(name="all", srcs=["."], visibility=["//visibility:public"])
diff --git a/WORKSPACE b/WORKSPACE
index ff17d5f..fcbae48 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -58,17 +58,18 @@
 
 # In order to run the Android integration tests, uncomment these rules, point
 # them to the Android NDK and the SDK, and point the bind rules under them
-# to @repository//:all.
-# new_local_repository(
-#     name = "globbed_android_sdk",
-#     path = "/usr/local/google/home/lberki/android/android-sdk-linux",
-#     build_file = "BUILD.glob"
+# to @repository//:files .
+# android_sdk_repository(
+#     name = "androidsdk",
+#     path = "/path/to/sdk",
+#     build_tools_version = "21.1.1",
+#     api_level = 19,
 # )
-#
-# new_local_repository(
-#     name = "globbed_android_ndk",
-#     path = "/usr/local/google/home/lberki/android/android-ndk",
-#     build_file = "BUILD.glob"
+
+# android_ndk_repository(
+#     name = "androidndk",
+#     path = "/path/to/ndk",
+#     api_level = 19,
 # )
 
 bind(
diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh
index 45d9308..d2616c4 100755
--- a/scripts/ci/build.sh
+++ b/scripts/ci/build.sh
@@ -69,28 +69,29 @@
     trap '[ -f WORKSPACE.bak ] && rm WORKSPACE && mv WORKSPACE.bak WORKSPACE' \
       EXIT
     cat >>WORKSPACE <<EOF
-new_local_repository(
-    name = "globbed_android_sdk",
+android_sdk_repository(
+    name = "androidsdk",
     path = "${ANDROID_SDK_PATH}",
-    build_file = "BUILD.glob",
+    build_tools_version = "${ANDROID_SDK_BUILD_TOOLS_VERSION:-22.0.1}",
+    api_level = ${ANDROID_SDK_API_LEVEL:-21},
 )
 
 bind(
     name = "android_sdk_for_testing",
-    actual = "@globbed_android_sdk//:all",
+    actual = "@androidsdk//:files",
 )
 EOF
     if [ -n "${ANDROID_NDK_PATH-}" ]; then
       cat >>WORKSPACE <<EOF
-new_local_repository(
-    name = "globbed_android_ndk",
+android_ndk_repository(
+    name = "androidndk",
     path = "${ANDROID_NDK_PATH}",
-    build_file = "BUILD.glob",
+    api_level = ${ANDROID_NDK_API_LEVEL:-21},
 )
 
 bind(
     name = "android_ndk_for_testing",
-    actual = "@globbed_android_ndk//:all",
+    actual = "@androidndk//:files",
 )
 EOF
     fi
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_suite_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_suite_template.txt
index be9258b..c8177e6 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_suite_template.txt
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_ndk_cc_toolchain_suite_template.txt
@@ -17,6 +17,11 @@
 
 package(default_visibility = ["//visibility:public"])
 
+filegroup(
+    name = "files",
+    srcs = ["ndk"],
+)
+
 cc_toolchain_suite(
     name = "toolchain",
     toolchains = {
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt
index 98833ad..aa899ac 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android_sdk_repository_template.txt
@@ -1,5 +1,10 @@
 package(default_visibility = ["//visibility:public"])
 
+filegroup(
+    name = "files",
+    srcs = ["."],
+)
+
 java_import(
     name = "appcompat_v7_import",
     jars = ["extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar"]
diff --git a/src/test/shell/bazel/android/android_integration_test.sh b/src/test/shell/bazel/android/android_integration_test.sh
index 1265091..023559c 100755
--- a/src/test/shell/bazel/android/android_integration_test.sh
+++ b/src/test/shell/bazel/android/android_integration_test.sh
@@ -157,12 +157,12 @@
   bazel build -s //java/bazel:bin || fail "build failed"
 }
 
-if [[ ! -r "${TEST_SRCDIR}/external/globbed_android_ndk/RELEASE.TXT" ]]; then
+if [[ ! -r "${TEST_SRCDIR}/external/androidndk/ndk/RELEASE.TXT" ]]; then
   echo "Not running Android tests due to lack of an Android NDK."
   exit 0
 fi
 
-if [[ ! -r "${TEST_SRCDIR}/external/globbed_android_sdk/SDK Readme.txt" ]]; then
+if [[ ! -r "${TEST_SRCDIR}/external/androidsdk/SDK Readme.txt" ]]; then
   echo "Not running Android tests due to lack of an Android SDK."
   exit 0
 fi
diff --git a/src/test/shell/bazel/test-setup.sh b/src/test/shell/bazel/test-setup.sh
index 5664986..e5de41b 100755
--- a/src/test/shell/bazel/test-setup.sh
+++ b/src/test/shell/bazel/test-setup.sh
@@ -188,8 +188,8 @@
   # TODO(bazel-team): This hard-codes the name of the Android repository in
   # the WORKSPACE file of Bazel. Change this once external repositories have
   # their own defined names under which they are mounted.
-  NDK_SRCDIR=$TEST_SRCDIR/external/globbed_android_ndk
-  SDK_SRCDIR=$TEST_SRCDIR/external/globbed_android_sdk
+  NDK_SRCDIR=$TEST_SRCDIR/external/androidndk/ndk
+  SDK_SRCDIR=$TEST_SRCDIR/external/androidsdk
 
   mkdir -p $ANDROID_NDK
   mkdir -p $ANDROID_SDK