From f9971e6b9acb32fbb090c73d257a1b67fb688f51 Mon Sep 17 00:00:00 2001 From: Damien Martin-Guillerez Date: Mon, 20 Apr 2015 13:51:07 +0000 Subject: Improved Eclipse support for the Bazel project Now the paths are 100% determined using Bazel query. To adapt to another project, change the variables at the top of the setup-eclipse.sh file. It also handles correctly java_plugins now. Because we must do queries on the full workspace, it is not easy to embed in a bazel build. I made a prototype for it but it is really impractical. -- MOS_MIGRATED_REVID=91580472 --- scripts/eclipse-generate.sh | 160 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100755 scripts/eclipse-generate.sh (limited to 'scripts/eclipse-generate.sh') diff --git a/scripts/eclipse-generate.sh b/scripts/eclipse-generate.sh new file mode 100755 index 0000000000..e53355055c --- /dev/null +++ b/scripts/eclipse-generate.sh @@ -0,0 +1,160 @@ +#!/bin/bash +# Copyright 2015 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generates eclipse files for Bazel + +set -eu + +progname=$0 +function usage() { + echo "Usage: $progname command args..." >&2 + echo "Possible commands are:" >&2 + echo " classpath java_paths lib_paths jre output_path" >&2 + echo " factorypath project_name plugin_paths" >&2 + echo " project project_name" >&2 + echo " apt_settings output_path" >&2 + exit 1 +} + +function read_entry() { + if [[ -e "${1// /_}" ]]; then + cat "$1" + else + echo "$1" + fi +} + +function generate_classpath() { + if [[ "$#" != 4 ]]; then + usage + fi + + java_paths="$(read_entry "$1")" + lib_paths="$(read_entry "$2")" + jre="$3" + output_path="$4" + + cat < + +EOF + + for path in $java_paths; do + echo " " + done + + for path_pair in $lib_paths; do + path_arr=(${path_pair//:/ }) + jar=${path_arr[0]} + source_path=${path_arr[1]-} + if [ -n "${source_path}" ]; then + echo " " + else + echo " " + fi + done + + # Write the end of the .classpath file + cat < + + + + + + +EOF +} + +function generate_factorypath() { + if [ "$#" != 2 ]; then + usage + fi + project_name="$1" + plugin_paths="$(read_entry "$2")" + + cat < + +EOF + + for path in $plugin_paths; do + echo " " + done + + # Write the end of the .factorypath file + cat < +EOF +} + +function generate_project() { + if [ "$#" != 1 ]; then + usage + fi + project_name=$1 + cat < + + ${project_name} + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + +EOF +} + +function generate_apt_settings() { + if [ "$#" != 1 ]; then + usage + fi + output_path=$1 + cat <