Damien Martin-Guillerez | bd6d60b | 2015-03-13 15:21:26 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2015 Google Inc. All rights reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | # Generates an Eclipse project. If a .project is not present, it will creates |
| 17 | # it and it will overwrite any .classpath file present |
| 18 | # |
| 19 | # Usage: ./setup-eclipse.sh |
| 20 | # |
| 21 | |
| 22 | set -eu |
Damien Martin-Guillerez | f9971e6 | 2015-04-20 13:51:07 +0000 | [diff] [blame] | 23 | TARGET=//src/... |
| 24 | JRE="JavaSE-1.8" |
| 25 | PROJECT_NAME="bazel" |
| 26 | OUTPUT_PATH="bazel-out/ide/classes" |
| 27 | GENERATED_PATH="bazel-out/ide/generated" |
| 28 | EXTRA_JARS="bazel-bazel/external/local-jdk/lib/tools.jar" |
Damien Martin-Guillerez | 9e51f22 | 2015-04-21 17:03:33 +0000 | [diff] [blame] | 29 | |
| 30 | cd $(dirname $(dirname "$0")) |
| 31 | |
| 32 | # Compile bazel |
| 33 | ([ -f "output/bazel" ] && [ -f "tools/jdk/JavaBuilder_deploy.jar" ] \ |
| 34 | && [ -f "tools/jdk/ijar" ] && [ -f "tools/jdk/SingleJar_deploy.jar" ] \ |
| 35 | && [ -e "tools/jdk/jdk" ]) || ./compile.sh >&2 || exit $? |
| 36 | |
| 37 | # Make the script use actual bazel |
| 38 | function bazel() { |
| 39 | ./output/bazel "$@" |
| 40 | } |
| 41 | |
| 42 | # |
| 43 | # End of part specific to bazel |
| 44 | # |
| 45 | source ./scripts/get_project_paths.sh |
Damien Martin-Guillerez | bd6d60b | 2015-03-13 15:21:26 +0000 | [diff] [blame] | 46 | |
Damien Martin-Guillerez | f9971e6 | 2015-04-20 13:51:07 +0000 | [diff] [blame] | 47 | mkdir -p ${OUTPUT_PATH} ${GENERATED_PATH} |
Damien Martin-Guillerez | bd6d60b | 2015-03-13 15:21:26 +0000 | [diff] [blame] | 48 | |
Damien Martin-Guillerez | f9971e6 | 2015-04-20 13:51:07 +0000 | [diff] [blame] | 49 | # Overwrite .classpath and .factorypath. |
| 50 | ./scripts/eclipse-generate.sh classpath "$JAVA_PATHS" "$LIB_PATHS $EXTRA_JARS" "$JRE" "$OUTPUT_PATH" >.classpath |
| 51 | if [ -n "$PLUGIN_PATHS" ]; then |
| 52 | ./scripts/eclipse-generate.sh factorypath "$PROJECT_NAME" "$PLUGIN_PATHS" >.factorypath |
| 53 | mkdir -p .settings |
| 54 | # Write apt settings if not present. |
| 55 | [ -e ".settings/org.eclipse.jdt.apt.core.prefs" ] || \ |
| 56 | ./scripts/eclipse-generate.sh apt_settings "$GENERATED_PATH" > .settings/org.eclipse.jdt.apt.core.prefs |
Damien Martin-Guillerez | bd6d60b | 2015-03-13 15:21:26 +0000 | [diff] [blame] | 57 | fi |
Damien Martin-Guillerez | f9971e6 | 2015-04-20 13:51:07 +0000 | [diff] [blame] | 58 | # Write .project if not present. |
| 59 | [ -e ".project" ] || \ |
| 60 | ./scripts/eclipse-generate.sh project "$PROJECT_NAME" > .project |
Damien Martin-Guillerez | bd6d60b | 2015-03-13 15:21:26 +0000 | [diff] [blame] | 61 | |
| 62 | echo |
| 63 | echo '***' |
| 64 | echo '*** Eclipse project generated' |
| 65 | echo '***' |
| 66 | echo |
| 67 | echo 'You can now import the bazel project into Eclipse.' |