diff options
author | Janak Ramakrishnan <janakr@janakr-macbookair2.roam.corp.google.com> | 2016-02-22 18:56:34 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-02-23 13:08:25 +0000 |
commit | 443c730fd1cdc8ae229c95823f9d7059aedb139f (patch) | |
tree | 3f06c2ddab6a4eb3964169ffeb30ba3e2f839079 /scripts | |
parent | cc30db9014996170357f4c1cba1aef308ee142c9 (diff) |
Make project generated by setup-intellij.sh error-free.
Fix three issues, one cosmetic, with setup-intellij.sh: running bazel
query "deps(${target}, 1)" on generated java files with a visibility
specification was returning two targets, one of which was the
visibility. Filtering for rules fixes that.
Bazel uses the javac langtools in third_party/ in preference to the
SDK's, but that wasn't reflected in the order of dependencies in the
module. This requires a small hack, since the SDK should appear before
some other jars in the dependencies.
Finally, remove some apparently dead code related to ijar that was just
printing errors when the script was run.
--
Change-Id: Iba5ae5a46c720282d99f193cd098ea14cc5eef52
Reviewed-on: https://bazel-review.googlesource.com/2990
MOS_MIGRATED_REVID=115246698
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/get_all_bazel_paths.sh | 10 | ||||
-rwxr-xr-x | scripts/setup-intellij.sh | 15 |
2 files changed, 16 insertions, 9 deletions
diff --git a/scripts/get_all_bazel_paths.sh b/scripts/get_all_bazel_paths.sh index 84f76a2c46..ffcee3c42f 100755 --- a/scripts/get_all_bazel_paths.sh +++ b/scripts/get_all_bazel_paths.sh @@ -68,7 +68,9 @@ function get_target_of() { function get_consuming_target() { # Here to the god of bazel, I should probably offer one or two memory chips for that local target=$(get_target_of $1) - local generating_target=$(query "deps(${target}, 1) - ${target}") + # Get the rule that generated this file. + local generating_target=$(query "kind(rule, deps(${target}, 1)) - ${target}") + [[ -n $generating_target ]] || echo "Couldn't get generating target for ${target}" 1>&2 local java_library=$(query "rdeps(//src/..., ${generating_target}, 1) - ${generating_target}") echo "${java_library}" } @@ -83,12 +85,6 @@ function collect_generated_paths() { 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 } diff --git a/scripts/setup-intellij.sh b/scripts/setup-intellij.sh index 424b0ba97f..cd4a19bf04 100755 --- a/scripts/setup-intellij.sh +++ b/scripts/setup-intellij.sh @@ -68,7 +68,6 @@ cat > $iml_file <<EOH <content url="file://\$MODULE_DIR$/out/generated"> <sourceFolder url="file://\$MODULE_DIR$/out/generated" isTestSource="false" generated="true" /> </content> - <orderEntry type="inheritedJdk" /> <content url="file://\$MODULE_DIR\$/src"> EOH @@ -140,8 +139,20 @@ EOF EOF } +# Slight hack to make sure (1) our langtools is picked up before the SDK +# default, but that (2) SDK is picked up before auto-value, because that +# apparently causes problems for auto-value otherwise. +readonly javac_jar="third_party/java/jdk/langtools/javac.jar" +write_jar_entry "$javac_jar" + +cat >> $iml_file <<'EOF' + <orderEntry type="inheritedJdk" /> +EOF + for jar in ${THIRD_PARTY_JAR_PATHS}; do - write_jar_entry $jar + if [[ jar != "$javac_jar" ]]; then + write_jar_entry $jar + fi done for path_pair in ${GENERATED_PATHS}; do |