Skip to content

Commit ff7c81a

Browse files
committed
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
1 parent 6b1155d commit ff7c81a

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

WORKSPACE

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
workspace(name = "gitiles")
22
load("//tools:bazlets.bzl", "load_bazlets")
3-
load_bazlets(commit = "3afbeab55ece585dbfc7a980bf7214b24ddbbe86")
3+
load_bazlets(
4+
commit = "e10ae3f85781aa15054be802b2a9f9465b1bf1e0",
5+
# local_path = "/home/<user>/projects/bazlets"
6+
)
47
load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl",
58
"maven_jar",
69
"GERRIT")

gitiles-dev/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ java_library(
1313
"//lib/slf4j:slf4j-simple",
1414
"//lib/soy",
1515
],
16+
visibility = ["//visibility:public"],
1617
)
1718

1819
java_binary(

gitiles-servlet/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ java_library(
5656
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests")
5757

5858
junit_tests(
59-
name = "ServletTests",
59+
name = "servlet_tests",
6060
srcs = glob(
6161
[
6262
"src/test/java/**/*Test.java",
6363
],
6464
exclude = ["**/ServletTest.java"],
6565
),
66-
visibility = ["//visibility:public"],
6766
runtime_deps = ["//lib/junit:hamcrest-core"],
6867
deps = DEPS + [
6968
":servlet",
@@ -73,6 +72,7 @@ junit_tests(
7372
"//lib/jgit:junit",
7473
"//lib/junit",
7574
],
75+
visibility = ["//visibility:public"],
7676
)
7777

7878
load("@com_googlesource_gerrit_bazlets//tools:javadoc.bzl", "java_doc")

tools/eclipse/BUILD

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
load("@com_googlesource_gerrit_bazlets//tools:classpath.bzl", "classpath_collector")
2+
load("@com_googlesource_gerrit_bazlets//tools:py_binary_path.bzl", "py_binary_path")
3+
4+
DEPS = [
5+
"//gitiles-servlet:servlet",
6+
"//gitiles-dev:lib",
7+
]
8+
9+
java_library(
10+
name = "classpath",
11+
runtime_deps = DEPS,
12+
)
13+
14+
classpath_collector(
15+
name = "main_classpath_collect",
16+
testonly = 1,
17+
deps = DEPS + [
18+
"//gitiles-servlet:servlet_tests",
19+
],
20+
)
21+
22+
# TODO(davido): This is a hack:
23+
# https://github.com/bazelbuild/bazel/issues/2452
24+
# We know the py_binary rule, but for *reasons* we cannot
25+
# use `buck run <rule>. Unfortunately, a query to retrieve
26+
# the path was removed in Bazel. So we are forced to do this
27+
# hack to access python script outside of the Bazel.
28+
py_binary_path(
29+
name = "project.py",
30+
py_binary_label = "@com_googlesource_gerrit_bazlets//tools/eclipse:project",
31+
)

tools/eclipse/project.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# Copyright (C) 2017 The Android Open Source Project
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+
bazel build tools/eclipse:project.py
17+
`bazel info output_base`/`cat bazel-bin/tools/eclipse/project.py.txt` -n gitiles -r .

0 commit comments

Comments
 (0)