Skip to content

Commit

Permalink
Update Dagger's Bazel setup.
Browse files Browse the repository at this point in the history
RELNOTES=N/A
PiperOrigin-RevId: 652556341
  • Loading branch information
bcorso authored and Dagger Team committed Jul 15, 2024
1 parent fb8bd41 commit 936ce88
Show file tree
Hide file tree
Showing 41 changed files with 973 additions and 221 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ 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"

# Enable MODULE.bazel
common --enable_bzlmod
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
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'
USE_BAZEL_VERSION: '7.2.1'
# 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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
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'
USE_BAZEL_VERSION: '7.2.1'
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
4 changes: 2 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@google_bazel_common//tools/jarjar:jarjar.bzl", "jarjar_library")
load("@google_bazel_common//tools/javadoc:javadoc.bzl", "javadoc_library")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain")
load("@rules_java//java:defs.bzl", "java_library")
load("//tools/jarjar:jarjar.bzl", "jarjar_library")
load("//tools/javadoc:javadoc.bzl", "javadoc_library")

package(default_visibility = ["//visibility:public"])

Expand Down
39 changes: 39 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.7.0",
)

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

bazel_dep(
name = "rules_jvm_external",
version = "6.2",
)

bazel_dep(
name = "rules_robolectric",
version = "4.13",
)
168 changes: 34 additions & 134 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# limitations under the License.


load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

#############################
# Load nested repository
#############################
Expand All @@ -27,129 +25,19 @@ local_repository(
)

#############################
# Load Bazel Skylib rules
# Load Android Sdk
#############################

BAZEL_SKYLIB_VERSION = "1.5.0"

BAZEL_SKYLIB_SHA = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94"

http_archive(
name = "bazel_skylib",
sha256 = BAZEL_SKYLIB_SHA,
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/%s/bazel-skylib-%s.tar.gz" % (BAZEL_SKYLIB_VERSION, BAZEL_SKYLIB_VERSION),
"https://github.com/bazelbuild/bazel-skylib/releases/download/%s/bazel-skylib-%s.tar.gz" % (BAZEL_SKYLIB_VERSION, BAZEL_SKYLIB_VERSION),
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

#############################
# Load rules_java repository
#############################

http_archive(
name = "rules_java",
sha256 = "c73336802d0b4882e40770666ad055212df4ea62cfa6edf9cb0f9d29828a0934",
url = "https://github.com/bazelbuild/rules_java/releases/download/5.3.5/rules_java-5.3.5.tar.gz",
)

####################################################
# Load Protobuf repository (needed by bazel-common)
####################################################

http_archive(
name = "rules_proto",
# output from `sha256sum` on the downloaded tar.gz file
sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1",
strip_prefix = "rules_proto-4.0.0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
],
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

#############################
# Load Bazel-Common repository
#############################

http_archive(
name = "google_bazel_common",
sha256 = "82a49fb27c01ad184db948747733159022f9464fc2e62da996fa700594d9ea42",
strip_prefix = "bazel-common-2a6b6406e12208e02b2060df0631fb30919080f3",
urls = ["https://github.com/google/bazel-common/archive/2a6b6406e12208e02b2060df0631fb30919080f3.zip"],
)

load("@google_bazel_common//:workspace_defs.bzl", "google_common_workspace_rules")

google_common_workspace_rules()

#############################
# Load Protobuf dependencies
#############################

# rules_python and zlib are required by protobuf.
# TODO(ronshapiro): Figure out if zlib is in fact necessary, or if proto can depend on the
# @bazel_tools library directly. See discussion in
# https://github.com/protocolbuffers/protobuf/pull/5389#issuecomment-481785716
# TODO(cpovirk): Should we eventually get rules_python from "Bazel Federation?"
# https://github.com/bazelbuild/rules_python#getting-started

http_archive(
name = "rules_python",
sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6",
strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27",
urls = ["https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz"],
)

http_archive(
name = "zlib",
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff",
strip_prefix = "zlib-1.2.11",
urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"],
android_sdk_repository(
name = "androidsdk",
api_level = 32,
build_tools_version = "32.0.0",
)

#############################
# Load Robolectric repository
#############################

ROBOLECTRIC_VERSION = "4.4"

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

load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")

robolectric_repositories()

#############################
# Load Kotlin repository
#############################

RULES_KOTLIN_TAG = "v1.8"

RULES_KOTLIN_SHA = "01293740a16e474669aba5b5a1fe3d368de5832442f164e4fbfc566815a8bc3a"

http_archive(
name = "io_bazel_rules_kotlin",
sha256 = RULES_KOTLIN_SHA,
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % RULES_KOTLIN_TAG],
)

load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "kotlinc_version")

KOTLIN_VERSION = "1.9.23"
Expand All @@ -172,23 +60,24 @@ kt_register_toolchains()
# Load Maven dependencies
#############################

RULES_JVM_EXTERNAL_TAG = "4.5"

RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"

http_archive(
name = "rules_jvm_external",
sha256 = RULES_JVM_EXTERNAL_SHA,
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:defs.bzl", "maven_install")

ANDROID_LINT_VERSION = "30.1.0"

ANT_VERSION = "1.9.6"

ASM_VERSION = "9.6"

AUTO_COMMON_VERSION = "1.2.1"

BYTE_BUDDY_VERSION = "1.9.10"

CHECKER_FRAMEWORK_VERSION = "2.5.3"

ECLIPSE_SISU_VERSION = "0.3.0"

ERROR_PRONE_VERSION = "2.14.0"

# NOTE(bcorso): Even though we set the version here, our Guava version in
# processor code will use whatever version is built into JavaBuilder, which is
# tied to the version of Bazel we're using.
Expand All @@ -198,14 +87,10 @@ GRPC_VERSION = "1.2.0"

INCAP_VERSION = "0.2"

BYTE_BUDDY_VERSION = "1.9.10"

CHECKER_FRAMEWORK_VERSION = "2.5.3"

ERROR_PRONE_VERSION = "2.14.0"

KSP_VERSION = KOTLIN_VERSION + "-1.0.19"

MAVEN_VERSION = "3.3.3"

maven_install(
artifacts = [
"androidx.annotation:annotation:1.1.0",
Expand Down Expand Up @@ -264,16 +149,27 @@ maven_install(
"io.grpc:grpc-protobuf:%s" % GRPC_VERSION,
"jakarta.inject:jakarta.inject-api:2.0.1",
"javax.annotation:javax.annotation-api:1.3.2",
"javax.enterprise:cdi-api:1.0",
"javax.inject:javax.inject:1",
"javax.inject:javax.inject-tck:1",
"junit:junit:4.13",
"net.bytebuddy:byte-buddy:%s" % BYTE_BUDDY_VERSION,
"net.bytebuddy:byte-buddy-agent:%s" % BYTE_BUDDY_VERSION,
"net.ltgt.gradle.incap:incap:%s" % INCAP_VERSION,
"net.ltgt.gradle.incap:incap-processor:%s" % INCAP_VERSION,
"org.apache.ant:ant:%s" % ANT_VERSION,
"org.apache.ant:ant-launcher:%s" % ANT_VERSION,
"org.apache.maven:maven-artifact:%s" % MAVEN_VERSION,
"org.apache.maven:maven-model:%s" % MAVEN_VERSION,
"org.apache.maven:maven-plugin-api:%s" % MAVEN_VERSION,
"org.checkerframework:checker-compat-qual:%s" % CHECKER_FRAMEWORK_VERSION,
"org.checkerframework:dataflow:%s" % CHECKER_FRAMEWORK_VERSION,
"org.checkerframework:javacutil:%s" % CHECKER_FRAMEWORK_VERSION,
"org.codehaus.plexus:plexus-utils:3.0.20",
"org.codehaus.plexus:plexus-classworlds:2.5.2",
"org.codehaus.plexus:plexus-component-annotations:1.5.5",
"org.eclipse.sisu:org.eclipse.sisu.plexus:%s" % ECLIPSE_SISU_VERSION,
"org.eclipse.sisu:org.eclipse.sisu.inject:%s" % ECLIPSE_SISU_VERSION,
"org.hamcrest:hamcrest-core:1.3",
"org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:%s" % KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-compiler-embeddable:%s" % KOTLIN_VERSION,
Expand All @@ -282,7 +178,11 @@ maven_install(
"org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.6.2",
"org.jspecify:jspecify:0.3.0",
"org.mockito:mockito-core:2.28.2",
"org.pantsbuild:jarjar:1.7.2",
"org.objenesis:objenesis:1.0",
"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
],
Expand Down
4 changes: 1 addition & 3 deletions build_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ DOCLINT_HTML_AND_SYNTAX = ["-Xdoclint:html,syntax"]

DOCLINT_REFERENCES = ["-Xdoclint:reference"]

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

POM_VERSION = "${project.version}"
4 changes: 2 additions & 2 deletions gwt/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "POM_VERSION")
load("//tools:maven.bzl", "pom_file")
load("//tools/maven:maven.bzl", "dagger_pom_file")

package(default_visibility = ["//:src"])

Expand All @@ -41,7 +41,7 @@ java_library(
visibility = ["//visibility:private"],
)

pom_file(
dagger_pom_file(
name = "pom",
artifact_id = "dagger-gwt",
artifact_name = "Dagger GWT",
Expand Down
2 changes: 1 addition & 1 deletion java/dagger/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load(
"JAVA_RELEASE_MIN",
"POM_VERSION",
)
load("//tools:maven.bzl", "gen_maven_artifact")
load("//tools/maven:maven.bzl", "gen_maven_artifact")

package(default_visibility = ["//:src"])

Expand Down
6 changes: 3 additions & 3 deletions java/dagger/android/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ load(
)
load("//tools:dejetify.bzl", "dejetified_library")
load(
"//tools:maven.bzl",
"//tools/maven:maven.bzl",
"dagger_pom_file",
"gen_maven_artifact",
"pom_file",
)

package(default_visibility = ["//:src"])
Expand Down Expand Up @@ -94,7 +94,7 @@ android_library(
],
)

pom_file(
dagger_pom_file(
name = "legacy-pom",
artifact_id = "dagger-android-legacy",
artifact_name = "Dagger Android Legacy",
Expand Down
2 changes: 1 addition & 1 deletion java/dagger/android/processor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load(
"DOCLINT_REFERENCES",
"POM_VERSION",
)
load("//tools:maven.bzl", "gen_maven_artifact")
load("//tools/maven:maven.bzl", "gen_maven_artifact")

package(default_visibility = ["//:src"])

Expand Down
Loading

0 comments on commit 936ce88

Please sign in to comment.