blob: 5bac977d269700ec086d07845855328d587ae2c5 [file] [log] [blame]
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +00001#!/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
22set -eu
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000023TARGET=//src/...
24JRE="JavaSE-1.8"
25PROJECT_NAME="bazel"
26OUTPUT_PATH="bazel-out/ide/classes"
27GENERATED_PATH="bazel-out/ide/generated"
28EXTRA_JARS="bazel-bazel/external/local-jdk/lib/tools.jar"
Damien Martin-Guillerez9e51f222015-04-21 17:03:33 +000029
30cd $(dirname $(dirname "$0"))
31
32# Compile bazel
Alex Humeskyd3f7eda2015-07-08 18:18:33 +000033([ -f "output/bazel" ] \
34 && [ -f "tools/jdk/JavaBuilder_deploy.jar" ] \
35 && [ -f "tools/jdk/ijar" ] \
36 && [ -f "tools/jdk/SingleJar_deploy.jar" ] \
37 && [ -f "tools/jdk/GenClass_deploy.jar" ] \
38 && [ -e "tools/jdk/jdk" ]) || ./compile.sh >&2 || exit $?
Damien Martin-Guillerez9e51f222015-04-21 17:03:33 +000039
40# Make the script use actual bazel
41function bazel() {
42 ./output/bazel "$@"
43}
44
45#
46# End of part specific to bazel
47#
48source ./scripts/get_project_paths.sh
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000049
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000050mkdir -p ${OUTPUT_PATH} ${GENERATED_PATH}
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000051
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000052# Overwrite .classpath and .factorypath.
53./scripts/eclipse-generate.sh classpath "$JAVA_PATHS" "$LIB_PATHS $EXTRA_JARS" "$JRE" "$OUTPUT_PATH" >.classpath
54if [ -n "$PLUGIN_PATHS" ]; then
55 ./scripts/eclipse-generate.sh factorypath "$PROJECT_NAME" "$PLUGIN_PATHS" >.factorypath
56 mkdir -p .settings
57 # Write apt settings if not present.
58 [ -e ".settings/org.eclipse.jdt.apt.core.prefs" ] || \
59 ./scripts/eclipse-generate.sh apt_settings "$GENERATED_PATH" > .settings/org.eclipse.jdt.apt.core.prefs
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000060fi
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000061# Write .project if not present.
62[ -e ".project" ] || \
63 ./scripts/eclipse-generate.sh project "$PROJECT_NAME" > .project
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000064
65echo
66echo '***'
67echo '*** Eclipse project generated'
68echo '***'
69echo
70echo 'You can now import the bazel project into Eclipse.'