Skip to content

Commit edd674b

Browse files
bcorsoDagger Team
authored andcommitted
Clean up Bazel workspace rules
* Added `.bazelversion` to declare Bazel version * Removed unused bazel common dependencies in WORKSPACE * Removed `bazel_skylib` * Removed `google_bazel_common` * Removed `rules_python` * Removed `zlib` * Removed obsolete `tools/bazel.rc` config RELNOTES=N/A PiperOrigin-RevId: 654352167
1 parent 140e201 commit edd674b

File tree

12 files changed

+73
-24
lines changed

12 files changed

+73
-24
lines changed

.bazelrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,23 @@ build --host_javacopt=-g
66
# TODO(ronshapiro): explore how much work it would be to reenable this
77
build --javacopt="-Xep:BetaApi:OFF"
88
build --host_javacopt="-Xep:BetaApi:OFF"
9+
10+
# Note: This flag is required to prevent actions from clashing with each when
11+
# reading/writing tmp files. Without this flag we get errors like:
12+
#
13+
# Error: Cannot use file /tmp/hsperfdata_runner/12 because it is locked by
14+
# another process
15+
#
16+
# This flag will be enabled by default in Bazel 7.0.0, but for now we enable it
17+
# manually. For more details: https://github.com/bazelbuild/bazel/issues/3236.
18+
build --incompatible_sandbox_hermetic_tmp
19+
20+
# Sets the JDK for compiling sources and executing tests.
21+
build --java_language_version=11
22+
build --tool_java_language_version=11
23+
build --java_runtime_version=remotejdk_11
24+
build --tool_java_runtime_version=remotejdk_11
25+
26+
# Sets the default source/target for Dagger's processors. Note that Dagger's api
27+
# libraries can target JDK 8, so we set it explicitly on the Bazel target.
28+
build --javacopt="-source 8 -target 11"

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.4.0

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ env:
1313
USE_JAVA_VERSION: '11'
1414
# This is required by AGP 8.3+.
1515
USE_JAVA_VERSION_FOR_PLUGIN: '17'
16-
# Our Bazel builds currently rely on 6.4.0. The version is set via
17-
# baselisk by USE_BAZEL_VERSION: https://github.com/bazelbuild/bazelisk.
18-
USE_BAZEL_VERSION: '6.4.0'
1916
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
2017
# https://issues.apache.org/jira/browse/MNG-7679
2118
USE_MAVEN_VERSION: '3.8.7'

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ env:
1212
USE_JAVA_VERSION: '11'
1313
# This is required by AGP 8.3+.
1414
USE_JAVA_VERSION_FOR_PLUGIN: '17'
15-
# Our Bazel builds currently rely on 6.4.0. The version is set via
16-
# baselisk by USE_BAZEL_VERSION: https://github.com/bazelbuild/bazelisk.
17-
USE_BAZEL_VERSION: '6.4.0'
1815
DAGGER_RELEASE_VERSION: "${{ github.event.inputs.dagger_release_version }}"
1916
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
2017
# https://issues.apache.org/jira/browse/MNG-7679

MODULE.bazel

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (C) 2024 The Dagger Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
bazel_dep(
16+
name = "bazel_skylib",
17+
version = "1.7.1",
18+
)
19+
20+
bazel_dep(
21+
name = "rules_java",
22+
version = "7.0.6",
23+
)
24+
25+
bazel_dep(
26+
name = "rules_kotlin",
27+
version = "1.9.0",
28+
repo_name = "io_bazel_rules_kotlin",
29+
)
30+
31+
bazel_dep(
32+
name = "rules_jvm_external",
33+
version = "5.3",
34+
)

WORKSPACE

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ http_archive(
118118
# Load Robolectric repository
119119
#############################
120120

121-
ROBOLECTRIC_VERSION = "4.4"
121+
ROBOLECTRIC_VERSION = "4.11.1"
122122

123123
http_archive(
124124
name = "robolectric",
125-
sha256 = "d4f2eb078a51f4e534ebf5e18b6cd4646d05eae9b362ac40b93831bdf46112c7",
125+
sha256 = "1ea1cfe67848decf959316e80dd69af2bbaa359ae2195efe1366cbdf3e968356",
126126
strip_prefix = "robolectric-bazel-%s" % ROBOLECTRIC_VERSION,
127-
urls = ["https://github.com/robolectric/robolectric-bazel/archive/%s.tar.gz" % ROBOLECTRIC_VERSION],
127+
urls = ["https://github.com/robolectric/robolectric-bazel/releases/download/%s/robolectric-bazel-%s.tar.gz" % (ROBOLECTRIC_VERSION, ROBOLECTRIC_VERSION)],
128128
)
129129

130130
load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
@@ -301,8 +301,8 @@ maven_install(
301301
"org.ow2.asm:asm:%s" % ASM_VERSION,
302302
"org.ow2.asm:asm-tree:%s" % ASM_VERSION,
303303
"org.ow2.asm:asm-commons:%s" % ASM_VERSION,
304-
"org.robolectric:robolectric:4.4",
305-
"org.robolectric:shadows-framework:4.4", # For ActivityController
304+
"org.robolectric:robolectric:%s" % ROBOLECTRIC_VERSION,
305+
"org.robolectric:shadows-framework:%s" % ROBOLECTRIC_VERSION, # For ActivityController
306306
],
307307
repositories = [
308308
"https://repo1.maven.org/maven2",

build_defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DOCLINT_HTML_AND_SYNTAX = ["-Xdoclint:html,syntax"]
1919
DOCLINT_REFERENCES = ["-Xdoclint:reference"]
2020

2121
JAVA_RELEASE_MIN = [
22-
"-source 7 -target 7",
22+
"-source 8 -target 8",
2323
]
2424

2525
POM_VERSION = "${project.version}"

java/dagger/android/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
load(
1919
"//:build_defs.bzl",
20+
"DOCLINT_HTML_AND_SYNTAX",
21+
"JAVA_RELEASE_MIN",
2022
"POM_VERSION",
2123
)
2224
load("//tools:dejetify.bzl", "dejetified_library")
@@ -43,6 +45,7 @@ filegroup(
4345
android_library(
4446
name = "android",
4547
srcs = SRCS,
48+
javacopts = JAVA_RELEASE_MIN + DOCLINT_HTML_AND_SYNTAX,
4649
plugins = [
4750
"//java/dagger/android/internal/proguard:plugin",
4851
],

java/dagger/android/support/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
load(
1919
"//:build_defs.bzl",
20+
"DOCLINT_HTML_AND_SYNTAX",
21+
"JAVA_RELEASE_MIN",
2022
"POM_VERSION",
2123
)
2224
load("//tools:dejetify.bzl", "dejetified_library")
@@ -36,6 +38,7 @@ filegroup(
3638
android_library(
3739
name = "support",
3840
srcs = glob(["*.java"]),
41+
javacopts = JAVA_RELEASE_MIN + DOCLINT_HTML_AND_SYNTAX,
3942
tags = ["maven_coordinates=com.google.dagger:dagger-android-support:" + POM_VERSION],
4043
deps = [
4144
"//:dagger_with_compiler",

test_defs.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
load("@rules_java//java:defs.bzl", "java_library", "java_test")
1818
load("//:build_defs.bzl", "JAVA_RELEASE_MIN")
19+
1920
load(
2021
"@io_bazel_rules_kotlin//kotlin:kotlin.bzl",
2122
"kt_jvm_library",
@@ -135,6 +136,7 @@ def GenJavaTests(
135136
shard_count = shard_count,
136137
functional = functional,
137138
require_jdk7_syntax = require_jdk7_syntax,
139+
# test_kwargs = {"add_exports": ["jdk.compiler/com.sun.tools.javac.api"]},
138140
)
139141

140142
def GenRobolectricTests(

0 commit comments

Comments
 (0)