Skip to content

Commit d59d27b

Browse files
authored
Add missing javax.annotation dependency (#320)
* Add missing javax.annotation dependency Fixes #321. Bazel/Dagger integration requires javax.annotation to be on the classpath to generate @generated annotation. Recent ErrorProne releases (started from 2.3.3) added new bug pattern: RefersToDaggerCodegen that is flagging the code as invalid, as it doesn't realize that the code is generated. Due to this problem, a previous attemt to bump EP version in Bazel was reverted. Fixing it would allow us to make another attempt to update EP version in Bazel. Test Plan: A. Involved approach: 1. Bump EP version to 2.3.4 in Bazel 2. Conduct custom java tools release with new EP version 3. Consume custom java tools release in WORKSPACE in rules_kotlin 4. Trying to bulid rules_kotlin would fail with RefersToDaggerCodegen error B. Simple approach: 1. Apply this patch 2. Build rules_kotlin 3. Confirm that this class: KotlinBuilderComponent_Module_ProvidePluginArgEncoderFactory is annotated with @generated annotation: @generated( value = "dagger.internal.codegen.ComponentProcessor", comments = "https://dagger.dev" ) @SuppressWarnings({ "unchecked", "rawtypes" }) public final class KotlinBuilderComponent_Module_ProvidePluginArgEncoderFactory [...] * Add javax.annotation to test_lib rule * compile.bzl: Remove superfluous paren * Run buildifier on BUILD files
1 parent 41fc492 commit d59d27b

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

examples/plugin/src/serialization/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("//kotlin:kotlin.bzl", "kt_compiler_plugin", "kt_jvm_library", "kt_jvm_test
33
kt_compiler_plugin(
44
name = "serialization_plugin",
55
deps = [
6-
"@com_github_jetbrains_kotlin//:kotlinx-serialization-compiler-plugin",
6+
"@com_github_jetbrains_kotlin//:kotlinx-serialization-compiler-plugin",
77
],
88
)
99

@@ -24,8 +24,8 @@ kt_jvm_test(
2424
test_class = "plugin.serialization.SerializationTest",
2525
deps = [
2626
":data",
27-
"@kotlin_rules_maven//:org_jetbrains_kotlinx_kotlinx_serialization_runtime",
2827
"@com_github_jetbrains_kotlin//:kotlin-reflect",
2928
"@kotlin_rules_maven//:junit_junit",
29+
"@kotlin_rules_maven//:org_jetbrains_kotlinx_kotlinx_serialization_runtime",
3030
],
31-
)
31+
)

kotlin/internal/jvm/compile.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ def _run_kt_builder_action(ctx, rule_kind, toolchains, dirs, srcs, friend, compi
329329
mnemonic = "KotlinCompile",
330330
inputs = depset(
331331
ctx.files.srcs,
332-
transitive = [compile_deps.compile_jars, transitive_runtime_jars]),
332+
transitive = [compile_deps.compile_jars, transitive_runtime_jars],
333+
),
333334
tools = tools,
334335
input_manifests = input_manifests,
335336
outputs = [f for f in outputs.values()],

kotlin/internal/repositories/setup.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def kt_configure():
4040
"com.google.dagger:dagger:2.26",
4141
"com.google.dagger:dagger-compiler:2.26",
4242
"com.google.dagger:dagger-producers:2.26",
43+
"javax.annotation:javax.annotation-api:1.3.2",
4344
"javax.inject:javax.inject:1",
4445
"org.pantsbuild:jarjar:1.7.2",
4546
],

src/main/kotlin/io/bazel/kotlin/builder/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ java_library(
3131
"//third_party:dagger",
3232
"@com_github_jetbrains_kotlin//:annotations",
3333
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
34+
"@kotlin_rules_maven//:javax_annotation_javax_annotation_api",
3435
"@kotlin_rules_maven//:javax_inject_javax_inject",
3536
],
3637
)

src/test/kotlin/io/bazel/kotlin/builder/BUILD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ java_library(
3434
"Deps.java",
3535
"DirectoryType.java",
3636
"KotlinAbstractTestBuilder.java",
37+
"KotlinBuilderTestComponent.java",
3738
"KotlinJsTestBuilder.java",
3839
"KotlinJvmTestBuilder.java",
39-
"KotlinBuilderTestComponent.java"
4040
],
4141
data = [
4242
"//src/main/kotlin/io/bazel/kotlin/compiler",
@@ -52,7 +52,8 @@ java_library(
5252
deps = _COMMON_DEPS + [
5353
"//third_party:autovalue",
5454
"//third_party:dagger",
55-
"//src/main/kotlin/io/bazel/kotlin/builder/tasks"
55+
"@kotlin_rules_maven//:javax_annotation_javax_annotation_api",
56+
"//src/main/kotlin/io/bazel/kotlin/builder/tasks",
5657
],
5758
)
5859

0 commit comments

Comments
 (0)