Bazel: Generate eclipse project servlet_api_2_5 can be exculded from the generated .classpath to avoid classpath collisions between Servlet API 2.5 and Servlet API 3.0. To do that, pass -x parameter to project.py invocation in project.sh: ... -n gitiles -r . -x servlet_api_2_5 TEST PLAN: $ tools/eclipse/project.sh Open the project in Eclipse IDE and verify that it can be compiled and the tests can be run. Change-Id: If318321fb1a94888a9adea635458afee2b463682
diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD new file mode 100644 index 0000000..45ad493 --- /dev/null +++ b/tools/eclipse/BUILD
@@ -0,0 +1,31 @@ +load("@com_googlesource_gerrit_bazlets//tools:classpath.bzl", "classpath_collector") +load("@com_googlesource_gerrit_bazlets//tools:py_binary_path.bzl", "py_binary_path") + +DEPS = [ + "//gitiles-servlet:servlet", + "//gitiles-dev:lib", +] + +java_library( + name = "classpath", + runtime_deps = DEPS, +) + +classpath_collector( + name = "main_classpath_collect", + testonly = 1, + deps = DEPS + [ + "//gitiles-servlet:servlet_tests", + ], +) + +# TODO(davido): This is a hack: +# https://github.com/bazelbuild/bazel/issues/2452 +# We know the py_binary rule, but for *reasons* we cannot +# use `buck run <rule>. Unfortunately, a query to retrieve +# the path was removed in Bazel. So we are forced to do this +# hack to access python script outside of the Bazel. +py_binary_path( + name = "project.py", + py_binary_label = "@com_googlesource_gerrit_bazlets//tools/eclipse:project", +)
diff --git a/tools/eclipse/project.sh b/tools/eclipse/project.sh new file mode 100755 index 0000000..e11daa0 --- /dev/null +++ b/tools/eclipse/project.sh
@@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright (C) 2017 The Android Open Source Project +# +# 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. + +bazel build tools/eclipse:project.py +`bazel info output_base`/`cat bazel-bin/tools/eclipse/project.py.txt` -n gitiles -r .