Skip to content

Commit 31eec2a

Browse files
bcorsoDagger Team
authored andcommitted
Update Bazel to use JDK 18.
This is required before updating to the latest XProcessing jars (which require JDK 17+). Note that we're not using JDK 17 because there's a bug that affects Dagger (https://bugs.openjdk.org/browse/JDK-8268575). This CL sets the default target level to 8, which is used by all of the processors, but some of the Dagger (non-processor) artifacts are set explicitly to target 7. Note that we're keeping the target low to avoid forcing downstream users to have to use a higher JDK. I've also added a validation step to our GitHub Actions to add some level of guarantee that the classes in the artifact jars all have the expected language level. RELNOTES=N/A PiperOrigin-RevId: 658131076
1 parent 5293ff5 commit 31eec2a

File tree

16 files changed

+285
-59
lines changed

16 files changed

+285
-59
lines changed

.bazelrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,27 @@ 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 other
11+
# when 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=18
22+
build --tool_java_language_version=18
23+
build --java_runtime_version=remotejdk_18
24+
build --tool_java_runtime_version=remotejdk_18
25+
26+
# Default source/target versions.
27+
build --javacopt="-source 8 -target 8"
28+
29+
# Workaround for https://openjdk.java.net/jeps/411.
30+
# See https://github.com/bazelbuild/bazel/issues/14502#issuecomment-1018366245.
31+
build --jvmopt="-Djava.security.manager=allow"
32+
build --jvmopt="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.4.0
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Artifact verification tests'
2+
description: 'Runs verification tests on the Dagger LOCAL-SNAPSHOT artifacts.'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: 'Check out repository'
8+
uses: actions/checkout@v3
9+
- name: 'Cache Gradle files'
10+
uses: actions/cache@v2
11+
with:
12+
path: |
13+
~/.gradle/caches
14+
~/.gradle/wrapper
15+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
16+
restore-keys: |
17+
${{ runner.os }}-gradle-
18+
- name: 'Download local snapshot for tests'
19+
uses: actions/download-artifact@v3
20+
with:
21+
name: local-snapshot
22+
path: ~/.m2/repository/com/google/dagger
23+
- name: 'Validate artifact jars'
24+
run: ./util/validate-artifacts.sh
25+
shell: bash

.github/workflows/ci.yml

Lines changed: 21 additions & 5 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'
@@ -43,6 +40,13 @@ jobs:
4340
steps:
4441
- uses: actions/checkout@v3
4542
- uses: ./.github/actions/bazel-test
43+
artifact-verification-tests:
44+
name: 'Artifact verification tests'
45+
needs: bazel-build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v3
49+
- uses: ./.github/actions/artifact-verification-tests
4650
artifact-java-local-tests:
4751
name: 'Artifact Java local tests'
4852
needs: bazel-build
@@ -98,7 +102,13 @@ jobs:
98102
name: 'Publish snapshot'
99103
# TODO(bcorso): Consider also waiting on artifact-android-emulator-tests
100104
# and artifact-android-emulator-legacy-api-tests after checking flakiness.
101-
needs: [bazel-test, artifact-java-local-tests, artifact-android-local-tests, test-gradle-plugin]
105+
needs: [
106+
bazel-test,
107+
artifact-verification-tests,
108+
artifact-java-local-tests,
109+
artifact-android-local-tests,
110+
test-gradle-plugin
111+
]
102112
if: github.event_name == 'push' && github.repository == 'google/dagger' && github.ref == 'refs/heads/master'
103113
runs-on: ubuntu-latest
104114
steps:
@@ -177,7 +187,13 @@ jobs:
177187
name: 'Clean up GitHub Action caches'
178188
# TODO(bcorso): Consider also waiting on artifact-android-emulator-tests
179189
# and artifact-android-emulator-legacy-api-tests after checking flakiness.
180-
needs: [bazel-test, artifact-java-local-tests, artifact-android-local-tests, test-gradle-plugin]
190+
needs: [
191+
bazel-test,
192+
artifact-verification-tests,
193+
artifact-java-local-tests,
194+
artifact-android-local-tests,
195+
test-gradle-plugin
196+
]
181197
runs-on: ubuntu-latest
182198
steps:
183199
- uses: actions/checkout@v3

.github/workflows/release.yml

Lines changed: 14 additions & 4 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
@@ -45,6 +42,13 @@ jobs:
4542
steps:
4643
- uses: actions/checkout@v3
4744
- uses: ./.github/actions/bazel-test
45+
artifact-verification-tests:
46+
name: 'Artifact verification tests'
47+
needs: bazel-build
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: ./.github/actions/artifact-verification-tests
4852
artifact-java-local-tests:
4953
name: 'Artifact Java local tests'
5054
needs: bazel-build
@@ -80,7 +84,13 @@ jobs:
8084
jdk: '${{ matrix.jdk }}'
8185
publish-artifacts:
8286
name: 'Publish Artifact'
83-
needs: [bazel-test, artifact-java-local-tests, artifact-android-local-tests, test-gradle-plugin]
87+
needs: [
88+
bazel-test,
89+
artifact-verification-tests,
90+
artifact-java-local-tests,
91+
artifact-android-local-tests,
92+
test-gradle-plugin
93+
]
8494
runs-on: ubuntu-latest
8595
steps:
8696
- name: 'Install Java ${{ env.USE_JAVA_VERSION }}'

BUILD

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ load("//tools/javadoc:javadoc.bzl", "javadoc_library")
1919

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

22-
define_kt_toolchain(
23-
name = "kotlin_toolchain",
24-
api_version = "1.4",
25-
jvm_target = "1.8",
26-
language_version = "1.4",
27-
)
28-
2922
package_group(
3023
name = "src",
3124
packages = ["//..."],
3225
)
3326

27+
define_kt_toolchain(
28+
name = "kotlin_toolchain",
29+
api_version = "1.6",
30+
jvm_target = "1.8",
31+
language_version = "1.6",
32+
)
33+
3434
java_library(
3535
name = "dagger_with_compiler",
3636
exported_plugins = ["//java/dagger/internal/codegen:component-codegen"],

WORKSPACE

Lines changed: 9 additions & 11 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")
@@ -135,14 +135,14 @@ robolectric_repositories()
135135
# Load Kotlin repository
136136
#############################
137137

138-
RULES_KOTLIN_TAG = "v1.8"
138+
RULES_KOTLIN_TAG = "1.9.6"
139139

140-
RULES_KOTLIN_SHA = "01293740a16e474669aba5b5a1fe3d368de5832442f164e4fbfc566815a8bc3a"
140+
RULES_KOTLIN_SHA = "3b772976fec7bdcda1d84b9d39b176589424c047eb2175bed09aac630e50af43"
141141

142142
http_archive(
143143
name = "io_bazel_rules_kotlin",
144144
sha256 = RULES_KOTLIN_SHA,
145-
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % RULES_KOTLIN_TAG],
145+
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v%s/rules_kotlin-v%s.tar.gz" % (RULES_KOTLIN_TAG, RULES_KOTLIN_TAG)],
146146
)
147147

148148
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "kotlinc_version")
@@ -159,9 +159,7 @@ kotlin_repositories(
159159
),
160160
)
161161

162-
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
163-
164-
kt_register_toolchains()
162+
register_toolchains("//:kotlin_toolchain")
165163

166164
#############################
167165
# Load Maven dependencies
@@ -301,8 +299,8 @@ maven_install(
301299
"org.ow2.asm:asm:%s" % ASM_VERSION,
302300
"org.ow2.asm:asm-tree:%s" % ASM_VERSION,
303301
"org.ow2.asm:asm-commons:%s" % ASM_VERSION,
304-
"org.robolectric:robolectric:4.4",
305-
"org.robolectric:shadows-framework:4.4", # For ActivityController
302+
"org.robolectric:robolectric:%s" % ROBOLECTRIC_VERSION,
303+
"org.robolectric:shadows-framework:%s" % ROBOLECTRIC_VERSION, # For ActivityController
306304
],
307305
repositories = [
308306
"https://repo1.maven.org/maven2",

gwt/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
# GWT-specific files for Dagger
1717

1818
load("@rules_java//java:defs.bzl", "java_library")
19-
load("//:build_defs.bzl", "POM_VERSION")
19+
load("//:build_defs.bzl", "JAVA_RELEASE_MIN", "POM_VERSION")
2020
load("//tools/maven:maven.bzl", "dagger_pom_file")
2121

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

2424
java_library(
2525
name = "gwt",
26+
javacopts = JAVA_RELEASE_MIN,
2627
resource_strip_prefix = "gwt/",
2728
resources = glob(["**/*.gwt.xml"]),
2829
tags = ["maven_coordinates=com.google.dagger:dagger-gwt:" + POM_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",

0 commit comments

Comments
 (0)