Skip to content

Commit

Permalink
Clean up Bazel workspace rules
Browse files Browse the repository at this point in the history
  * 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
  • Loading branch information
bcorso authored and Dagger Team committed Jul 21, 2024
1 parent 140e201 commit edd674b
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 24 deletions.
20 changes: 20 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,23 @@ build --host_javacopt=-g
# TODO(ronshapiro): explore how much work it would be to reenable this
build --javacopt="-Xep:BetaApi:OFF"
build --host_javacopt="-Xep:BetaApi:OFF"

# Note: This flag is required to prevent actions from clashing with each when
# reading/writing tmp files. Without this flag we get errors like:
#
# Error: Cannot use file /tmp/hsperfdata_runner/12 because it is locked by
# another process
#
# This flag will be enabled by default in Bazel 7.0.0, but for now we enable it
# manually. For more details: https://github.com/bazelbuild/bazel/issues/3236.
build --incompatible_sandbox_hermetic_tmp

# Sets the JDK for compiling sources and executing tests.
build --java_language_version=11
build --tool_java_language_version=11
build --java_runtime_version=remotejdk_11
build --tool_java_runtime_version=remotejdk_11

# Sets the default source/target for Dagger's processors. Note that Dagger's api
# libraries can target JDK 8, so we set it explicitly on the Bazel target.
build --javacopt="-source 8 -target 11"
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.4.0
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ env:
USE_JAVA_VERSION: '11'
# This is required by AGP 8.3+.
USE_JAVA_VERSION_FOR_PLUGIN: '17'
# Our Bazel builds currently rely on 6.4.0. The version is set via
# baselisk by USE_BAZEL_VERSION: https://github.com/bazelbuild/bazelisk.
USE_BAZEL_VERSION: '6.4.0'
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
# https://issues.apache.org/jira/browse/MNG-7679
USE_MAVEN_VERSION: '3.8.7'
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ env:
USE_JAVA_VERSION: '11'
# This is required by AGP 8.3+.
USE_JAVA_VERSION_FOR_PLUGIN: '17'
# Our Bazel builds currently rely on 6.4.0. The version is set via
# baselisk by USE_BAZEL_VERSION: https://github.com/bazelbuild/bazelisk.
USE_BAZEL_VERSION: '6.4.0'
DAGGER_RELEASE_VERSION: "${{ github.event.inputs.dagger_release_version }}"
# The default Maven 3.9.0 has a regression so we manually install 3.8.7.
# https://issues.apache.org/jira/browse/MNG-7679
Expand Down
34 changes: 34 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (C) 2024 The Dagger Authors.
#
# 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_dep(
name = "bazel_skylib",
version = "1.7.1",
)

bazel_dep(
name = "rules_java",
version = "7.0.6",
)

bazel_dep(
name = "rules_kotlin",
version = "1.9.0",
repo_name = "io_bazel_rules_kotlin",
)

bazel_dep(
name = "rules_jvm_external",
version = "5.3",
)
10 changes: 5 additions & 5 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ http_archive(
# Load Robolectric repository
#############################

ROBOLECTRIC_VERSION = "4.4"
ROBOLECTRIC_VERSION = "4.11.1"

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

load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
Expand Down Expand Up @@ -301,8 +301,8 @@ maven_install(
"org.ow2.asm:asm:%s" % ASM_VERSION,
"org.ow2.asm:asm-tree:%s" % ASM_VERSION,
"org.ow2.asm:asm-commons:%s" % ASM_VERSION,
"org.robolectric:robolectric:4.4",
"org.robolectric:shadows-framework:4.4", # For ActivityController
"org.robolectric:robolectric:%s" % ROBOLECTRIC_VERSION,
"org.robolectric:shadows-framework:%s" % ROBOLECTRIC_VERSION, # For ActivityController
],
repositories = [
"https://repo1.maven.org/maven2",
Expand Down
2 changes: 1 addition & 1 deletion build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DOCLINT_HTML_AND_SYNTAX = ["-Xdoclint:html,syntax"]
DOCLINT_REFERENCES = ["-Xdoclint:reference"]

JAVA_RELEASE_MIN = [
"-source 7 -target 7",
"-source 8 -target 8",
]

POM_VERSION = "${project.version}"
3 changes: 3 additions & 0 deletions java/dagger/android/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

load(
"//:build_defs.bzl",
"DOCLINT_HTML_AND_SYNTAX",
"JAVA_RELEASE_MIN",
"POM_VERSION",
)
load("//tools:dejetify.bzl", "dejetified_library")
Expand All @@ -43,6 +45,7 @@ filegroup(
android_library(
name = "android",
srcs = SRCS,
javacopts = JAVA_RELEASE_MIN + DOCLINT_HTML_AND_SYNTAX,
plugins = [
"//java/dagger/android/internal/proguard:plugin",
],
Expand Down
3 changes: 3 additions & 0 deletions java/dagger/android/support/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

load(
"//:build_defs.bzl",
"DOCLINT_HTML_AND_SYNTAX",
"JAVA_RELEASE_MIN",
"POM_VERSION",
)
load("//tools:dejetify.bzl", "dejetified_library")
Expand All @@ -36,6 +38,7 @@ filegroup(
android_library(
name = "support",
srcs = glob(["*.java"]),
javacopts = JAVA_RELEASE_MIN + DOCLINT_HTML_AND_SYNTAX,
tags = ["maven_coordinates=com.google.dagger:dagger-android-support:" + POM_VERSION],
deps = [
"//:dagger_with_compiler",
Expand Down
2 changes: 2 additions & 0 deletions test_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

load("@rules_java//java:defs.bzl", "java_library", "java_test")
load("//:build_defs.bzl", "JAVA_RELEASE_MIN")

load(
"@io_bazel_rules_kotlin//kotlin:kotlin.bzl",
"kt_jvm_library",
Expand Down Expand Up @@ -135,6 +136,7 @@ def GenJavaTests(
shard_count = shard_count,
functional = functional,
require_jdk7_syntax = require_jdk7_syntax,
# test_kwargs = {"add_exports": ["jdk.compiler/com.sun.tools.javac.api"]},
)

def GenRobolectricTests(
Expand Down
11 changes: 0 additions & 11 deletions tools/bazel.rc

This file was deleted.

5 changes: 4 additions & 1 deletion tools/maven/maven.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ def _validate_list(name, actual_list, expected_list, banned_list = []):
fail("\t[Error]: Found banned {}: \n\t\t".format(name) + "\n\t\t".join(banned))

def _strip_artifact_version(artifact):
return artifact.rsplit(":", 1)[0]
artifact = artifact.rsplit(":", 1)[0]
if artifact.endswith(":aar"):
return artifact.rsplit(":aar", 1)[0]
return artifact

_validate_maven_deps = rule(
implementation = _validate_maven_deps_impl,
Expand Down

0 comments on commit edd674b

Please sign in to comment.