blob: 89c8ea078c6421f80aa4a0ef3961546ab36e2818 [file] [log] [blame]
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +00001#!/bin/sh
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00002# Copyright 2015 The Bazel Authors. All rights reserved.
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +00003#
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
Lukacs Berki69216422016-01-20 13:48:43 +000023TARGET=$(echo //src/{main,java_tools,test/{java,cpp}}/... //third_party/... \
24 -//third_party/ijar/test/... -//third_party/java/j2objc/...)
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000025JRE="JavaSE-1.8"
26PROJECT_NAME="bazel"
27OUTPUT_PATH="bazel-out/ide/classes"
28GENERATED_PATH="bazel-out/ide/generated"
Kristina Chodorow88821142016-01-26 18:00:14 +000029EXTRA_JARS="bazel-bazel/external/local_jdk/lib/tools.jar"
Damien Martin-Guillerez9e51f222015-04-21 17:03:33 +000030
31cd $(dirname $(dirname "$0"))
32
33# Compile bazel
Lukacs Berki69216422016-01-20 13:48:43 +000034[ -f "output/bazel" ] || ./compile.sh >&2 || exit $?
Damien Martin-Guillerez9e51f222015-04-21 17:03:33 +000035
36# Make the script use actual bazel
37function bazel() {
38 ./output/bazel "$@"
39}
40
41#
42# End of part specific to bazel
43#
44source ./scripts/get_project_paths.sh
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000045
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000046mkdir -p ${OUTPUT_PATH} ${GENERATED_PATH}
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000047
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000048# Overwrite .classpath and .factorypath.
49./scripts/eclipse-generate.sh classpath "$JAVA_PATHS" "$LIB_PATHS $EXTRA_JARS" "$JRE" "$OUTPUT_PATH" >.classpath
50if [ -n "$PLUGIN_PATHS" ]; then
51 ./scripts/eclipse-generate.sh factorypath "$PROJECT_NAME" "$PLUGIN_PATHS" >.factorypath
52 mkdir -p .settings
53 # Write apt settings if not present.
54 [ -e ".settings/org.eclipse.jdt.apt.core.prefs" ] || \
55 ./scripts/eclipse-generate.sh apt_settings "$GENERATED_PATH" > .settings/org.eclipse.jdt.apt.core.prefs
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000056fi
Damien Martin-Guillerezf9971e62015-04-20 13:51:07 +000057# Write .project if not present.
58[ -e ".project" ] || \
59 ./scripts/eclipse-generate.sh project "$PROJECT_NAME" > .project
Damien Martin-Guillerezbd6d60b2015-03-13 15:21:26 +000060
61echo
62echo '***'
63echo '*** Eclipse project generated'
64echo '***'
65echo
66echo 'You can now import the bazel project into Eclipse.'