Skip to content

Commit

Permalink
Update CI to build Dagger with java 11.
Browse files Browse the repository at this point in the history
This changes is needed to continue using XProcessing. All of androidx is now built with `--target 11`.

RELNOTES=N/A
PiperOrigin-RevId: 460256277
  • Loading branch information
bcorso authored and Dagger Team committed Jul 11, 2022
1 parent e591833 commit 37f3ddb
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/actions/artifact-android-local-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ runs:
with:
name: local-snapshot
path: ~/.m2/repository/com/google/dagger
- name: 'Setup JDK'
- name: 'Install Java ${{ env.USE_JAVA_VERSION }}'
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
java-version: '${{ env.USE_JAVA_VERSION }}'
- name: 'Gradle Android local tests (AGP ${{ inputs.agp }})'
run: ./util/run-local-gradle-android-tests.sh "${{ inputs.agp }}"
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/test-gradle-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ description: 'Tests the Hilt Gradle plugin.'
runs:
using: "composite"
steps:
- name: 'Install Java 11'
- name: 'Install Java ${{ env.USE_JAVA_VERSION }}'
uses: actions/setup-java@v2
with:
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
java-version: '11'
distribution: '${{ env.USE_JAVA_DISTRIBUTION }}'
java-version: '${{ env.USE_JAVA_VERSION }}'
- name: 'Check out repository'
uses: actions/checkout@v2
- name: 'Cache local Maven repository'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ on:

env:
USE_JAVA_DISTRIBUTION: 'zulu'
# Our Bazel builds currently rely on JDK 8.
USE_JAVA_VERSION: '8'
USE_JAVA_VERSION: '11'
# Our Bazel builds currently rely on 4.2.1. The version is set via
# baselisk by USE_BAZEL_VERSION: https://github.com/bazelbuild/bazelisk.
USE_BAZEL_VERSION: '4.2.1'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ on:

env:
USE_JAVA_DISTRIBUTION: 'zulu'
# Our Bazel builds currently rely on JDK 8.
USE_JAVA_VERSION: '8'
USE_JAVA_VERSION: '11'
# Our Bazel builds currently rely on 4.2.1. The version is set via
# baselisk by USE_BAZEL_VERSION: https://github.com/bazelbuild/bazelisk.
USE_BAZEL_VERSION: '4.2.1'
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ maven_install(
"com.google.auto.factory:auto-factory:1.0",
"com.google.auto.service:auto-service:1.0",
"com.google.auto.service:auto-service-annotations:1.0",
"com.google.auto.value:auto-value:1.6",
"com.google.auto.value:auto-value-annotations:1.6",
"com.google.auto.value:auto-value:1.9",
"com.google.auto.value:auto-value-annotations:1.9",
"com.google.code.findbugs:jsr305:3.0.1",
"com.google.devtools.ksp:symbol-processing:%s" % KSP_VERSION,
"com.google.devtools.ksp:symbol-processing-api:%s" % KSP_VERSION,
Expand Down
5 changes: 3 additions & 2 deletions java/dagger/hilt/android/processor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ gen_maven_artifact(
],
javadoc_android_api_level = 30,
javadoc_root_packages = [
"dagger.hilt.processor",
"dagger.hilt.android.processor",
# Java 11 javadocs requires non-empty root package so use ".internal" as the root package.
"dagger.hilt.processor.internal",
"dagger.hilt.android.processor.internal",
],
javadoc_srcs = [
"//java/dagger/hilt:hilt_processing_filegroup",
Expand Down
5 changes: 3 additions & 2 deletions java/dagger/hilt/processor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ gen_maven_artifact(
],
javadoc_android_api_level = 30,
javadoc_root_packages = [
"dagger.hilt.processor",
"dagger.hilt.android.processor",
# Java 11 javadocs requires non-empty root package so use ".internal" as the root package.
"dagger.hilt.processor.internal",
"dagger.hilt.android.processor.internal",
],
javadoc_srcs = [
"//java/dagger/hilt:hilt_processing_filegroup",
Expand Down
3 changes: 3 additions & 0 deletions java/dagger/internal/codegen/kythe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ java_library(
deps = [
":kythe_plugin",
"//java/dagger:core",
"//java/dagger/internal/codegen/base",
"//java/dagger/internal/codegen/binding",
"//java/dagger/internal/codegen/javac",
"//java/dagger/internal/codegen/javapoet",
"//java/dagger/internal/codegen/kotlin",
"//java/dagger/internal/codegen/langmodel",
"//java/dagger/internal/codegen/validation",
"//java/dagger/internal/codegen/xprocessing",
"//java/dagger/spi",
"//third_party/java/auto:service",
"//third_party/java/error_prone:annotations",
"//third_party/java/guava/collect",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ public void copyConstructorParametersConvertsAndroidInternalNullableToExternal()
"@Generated(\"dagger.hilt.android.processor.internal.androidentrypoint.ViewGenerator\")",
"abstract class Hilt_MyView extends View implements",
"GeneratedComponentManagerHolder {",
// The generated parameter names are copied from the base class. Since we only have
// the jar and not the source for these base classes the parameter names are missing
" Hilt_MyView(Context arg0, @Nullable AttributeSet arg1) {",
" super(arg0, arg1);",
" Hilt_MyView(Context context, @Nullable AttributeSet attrs) {",
" super(context, attrs);",
" inject();",
" }",
"}"));
Expand Down
1 change: 1 addition & 0 deletions javatests/dagger/internal/codegen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ GenJavaTests(
"//third_party/java/guava/collect",
"//third_party/java/guava/util/concurrent",
"//third_party/java/javapoet",
"//third_party/java/jsr250_annotations", # Include @Generated in generated files.
"//third_party/java/jsr330_inject",
"//third_party/java/junit",
"//third_party/java/mockito",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ public void productionComponents() throws Exception {
Compilation compilation =
compilerWithOptions(
ImmutableList.<String>builder()
.add("-source", "7", "-target", "7")
.addAll(compilerMode.javacopts())
.build())
.compile(mapModuleFile, componentFile);
Expand All @@ -278,11 +277,6 @@ public void productionComponents() throws Exception {
.hasSourceEquivalentTo(
JavaFileObjects.forSourceString(
"test.DaggerTestComponent",
goldenFileRule.goldenFileContent("test.DaggerTestComponent")
// The golden files were generated with jdk 11, and we expect an extra cast in jdk 7
.replace(
"return Futures.immediateFuture(ImmutableMap.<String, String>of());",
"return Futures.immediateFuture("
+ "(Map<String, String>) ImmutableMap.<String, String>of());")));
goldenFileRule.goldenFileContent("test.DaggerTestComponent")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,17 @@ public void providesMethodReturnsProduced() {

Compilation compilation = daggerCompiler().compile(module);
assertThat(compilation).failed();
// In java 11, errors reported on individual items in an annotation value's list will show up
// as separate errors to the user on the associated lines reported. However, in java 8, errors
// reported on individual items in an annotation value's list will show up as a single error
// (which ever is reported first) on the list itself, rather than on the items reported.
assertThat(compilation).hadErrorCount(1);
assertThat(compilation).hadErrorCount(2);
assertThat(compilation)
.hadErrorContaining(
"java.lang.Void is listed as a module, but is not annotated with @Module");
"java.lang.Void is listed as a module, but is not annotated with @Module")
.inFile(module)
.onLine(7);
assertThat(compilation)
.hadErrorContaining(
"java.lang.String is listed as a module, but is not annotated with @Module")
.inFile(module)
.onLine(8);
}

@Test public void singleProvidesMethodNoArgs() {
Expand Down
3 changes: 2 additions & 1 deletion javatests/dagger/internal/codegen/ModuleValidationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public void moduleIncludesSelfCycle() {
Compilation compilation = daggerCompiler().compile(module, otherModule);
assertThat(compilation).failed();
String error = String.format("@%s cannot include themselves", moduleType.simpleName());
assertThat(compilation).hadErrorContaining(error).inFile(module).onLineContaining("Module(");
assertThat(compilation).hadErrorContaining(error).inFile(module).onLineContaining("// first");
assertThat(compilation).hadErrorContaining(error).inFile(module).onLineContaining("// second");
}
}
1 change: 1 addition & 0 deletions third_party/java/auto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ java_library(
],
tags = ["maven:compile_only"],
exports = [
"//third_party/java/error_prone:annotations",
"@maven//:com_google_auto_value_auto_value_annotations",
],
)
Expand Down
1 change: 0 additions & 1 deletion third_party/java/compile_testing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ java_library(
"//third_party/java/jsr305_annotations",
"//third_party/java/junit",
"//third_party/java/truth",
"@local_jdk//:lib/tools.jar",
],
)

0 comments on commit 37f3ddb

Please sign in to comment.