Update setup-intellij to get it working again.

This is just based on what I had to do to get IntelliJ working with
Bazel at head, but I think it makes things simpler as well.

Main changes:
* External jars are supported (I think);
* Protobufs are imported en masse via a "directory" module library;
* We now include all Android files unless it looks like we won't be
able to compile them.

--
Change-Id: Ib2ce59f6636f0d262b05f89d57837d7018a0fbfc
Reviewed-on: https://bazel-review.googlesource.com/1611
MOS_MIGRATED_REVID=98118522
diff --git a/scripts/get_all_bazel_paths.sh b/scripts/get_all_bazel_paths.sh
index b64ff40..4a0cbfe 100755
--- a/scripts/get_all_bazel_paths.sh
+++ b/scripts/get_all_bazel_paths.sh
@@ -38,23 +38,16 @@
 ./output/bazel build -- //src/... //third_party/... \
   -//third_party/ijar/test/... -//src/tools/{xcode,android}/... >&2 || exit $?
 
-# Path IDE should put its output files in.
-IDE_OUTPUT_PATH="bazel-out/ide-classes"
-
 # Source roots.
 JAVA_PATHS="$(find src -name "*.java" | sed "s|/com/google/.*$||" | sort -u)"
 if [ "$(uname -s | tr 'A-Z' 'a-z')" != "darwin" ]; then
   JAVA_PATHS="$(echo "${JAVA_PATHS}" | fgrep -v "/objc_tools/")"
 fi
-# Android doesn't work out of the box, but should we tell users to install the
-# Android SDK?
-JAVA_PATHS="$(echo "${JAVA_PATHS}" | fgrep -v "/android/")"
 
 THIRD_PARTY_JAR_PATHS="$(find third_party -name "*.jar" | sort -u)"
 
-# Generated protobuf files have special jar files and output into .proto_output
-# directories.
-PROTOBUF_PATHS="$(find bazel-bin/ -name "*.java" | grep proto | sed "s|/com/google/.*$||" | sort -u | sed 's|//|/|')"
+# Android-SDK-dependent files may need to be excluded from compilation.
+ANDROID_IMPORTING_FILES="$(grep "^import android\." -R -l --include "*.java" src | sort)"
 
 # All other generated libraries.
 readonly package_list=$(find src -name "BUILD" | sed "s|/BUILD||" | sed "s|^|//|")
@@ -94,6 +87,12 @@
   for path in $(find bazel-genfiles/ -name "*.java" | sed 's|/\{0,1\}bazel-genfiles/\{1,2\}|//|' | uniq); do
     source_path=$(echo ${path} | sed 's|//|bazel-genfiles/|' | sed 's|/com/.*$||')
     echo "$(get_containing_library ${path}):${source_path}"
+  done &&
+  # Add in "external" jars which don't have source paths.
+  for jardir in "jar/" ""; do
+    for path in $(find bazel-genfiles/${jardir}_ijar -name "*.jar" | sed 's|^/+||' | uniq); do
+      echo "${path}:"
+    done
   done | sort -u
 }