Skip to content

Commit e10b48b

Browse files
bcorsoDagger Team
authored andcommitted
Upgrade XProcessing jars.
RELNOTES=N/A PiperOrigin-RevId: 720198398
1 parent c63e003 commit e10b48b

File tree

9 files changed

+162
-188
lines changed

9 files changed

+162
-188
lines changed

WORKSPACE

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ KOTLIN_VERSION = "2.0.21"
210210

211211
KSP_VERSION = KOTLIN_VERSION + "-1.0.28"
212212

213+
# XProcessing testing uses the embeddable Kotlin version. Ideally, this would be
214+
# the same as KOTLIN_VERSION, but XProcessing testing requires 2.1.0 and Bazel
215+
# doesn't support 2.1.0 yet. See https://github.com/bazelbuild/rules_kotlin/issues/1176.
216+
EMBEDDABLE_KOTLIN_VERSION = "2.1.0"
217+
218+
EMBEDDABLE_KSP_VERSION = EMBEDDABLE_KOTLIN_VERSION + "-1.0.28"
219+
213220
MAVEN_VERSION = "3.3.3"
214221

215222
maven_install(
@@ -251,7 +258,6 @@ maven_install(
251258
"com.google.devtools.ksp:symbol-processing:%s" % KSP_VERSION,
252259
"com.google.devtools.ksp:symbol-processing-api:%s" % KSP_VERSION,
253260
"com.google.devtools.ksp:symbol-processing-common-deps:%s" % KSP_VERSION,
254-
"com.google.devtools.ksp:symbol-processing-aa-embeddable:%s" % KSP_VERSION,
255261
"com.google.errorprone:error_prone_annotation:%s" % ERROR_PRONE_VERSION,
256262
"com.google.errorprone:error_prone_annotations:%s" % ERROR_PRONE_VERSION,
257263
"com.google.errorprone:error_prone_check_api:%s" % ERROR_PRONE_VERSION,
@@ -294,9 +300,6 @@ maven_install(
294300
"org.eclipse.sisu:org.eclipse.sisu.plexus:%s" % ECLIPSE_SISU_VERSION,
295301
"org.eclipse.sisu:org.eclipse.sisu.inject:%s" % ECLIPSE_SISU_VERSION,
296302
"org.hamcrest:hamcrest-core:1.3",
297-
"org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:%s" % KOTLIN_VERSION,
298-
"org.jetbrains.kotlin:kotlin-compiler-embeddable:%s" % KOTLIN_VERSION,
299-
"org.jetbrains.kotlin:kotlin-daemon-embeddable:%s" % KOTLIN_VERSION,
300303
"org.jetbrains.kotlin:kotlin-metadata-jvm:%s" % KOTLIN_VERSION,
301304
"org.jetbrains.kotlin:kotlin-stdlib:%s" % KOTLIN_VERSION,
302305
"org.jspecify:jspecify:1.0.0",
@@ -314,3 +317,20 @@ maven_install(
314317
"https://maven.google.com",
315318
],
316319
)
320+
321+
maven_install(
322+
name = "kotlin_embeddable",
323+
artifacts = [
324+
"com.google.devtools.ksp:symbol-processing:%s" % EMBEDDABLE_KSP_VERSION,
325+
"com.google.devtools.ksp:symbol-processing-aa-embeddable:%s" % EMBEDDABLE_KSP_VERSION,
326+
"org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:%s" % EMBEDDABLE_KOTLIN_VERSION,
327+
"org.jetbrains.kotlin:kotlin-compiler-embeddable:%s" % EMBEDDABLE_KOTLIN_VERSION,
328+
"org.jetbrains.kotlin:kotlin-daemon-embeddable:%s" % EMBEDDABLE_KOTLIN_VERSION,
329+
"org.jetbrains.kotlin:kotlin-metadata-jvm:%s" % EMBEDDABLE_KOTLIN_VERSION,
330+
"org.jetbrains.kotlin:kotlin-stdlib:%s" % EMBEDDABLE_KOTLIN_VERSION,
331+
],
332+
repositories = [
333+
"https://repo1.maven.org/maven2",
334+
"https://maven.google.com",
335+
],
336+
)

java/dagger/internal/codegen/xprocessing/BUILD

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ java_library(
6363
testonly = 1,
6464
exports = [
6565
":xprocessing-testing-lib",
66-
"@maven//:com_google_devtools_ksp_symbol_processing",
67-
"@maven//:com_google_devtools_ksp_symbol_processing_aa_embeddable",
68-
"@maven//:com_google_devtools_ksp_symbol_processing_common_deps",
69-
"@maven//:org_jetbrains_kotlin_kotlin_annotation_processing_embeddable",
70-
"@maven//:org_jetbrains_kotlin_kotlin_compiler_embeddable",
71-
"@maven//:org_jetbrains_kotlin_kotlin_daemon_embeddable",
66+
"@kotlin_embeddable//:com_google_devtools_ksp_symbol_processing",
67+
"@kotlin_embeddable//:com_google_devtools_ksp_symbol_processing_aa_embeddable",
68+
"@kotlin_embeddable//:com_google_devtools_ksp_symbol_processing_common_deps",
69+
"@kotlin_embeddable//:org_jetbrains_kotlin_kotlin_annotation_processing_embeddable",
70+
"@kotlin_embeddable//:org_jetbrains_kotlin_kotlin_compiler_embeddable",
71+
"@kotlin_embeddable//:org_jetbrains_kotlin_kotlin_daemon_embeddable",
7272
],
7373
)
7474

497 Bytes
Binary file not shown.
-993 KB
Binary file not shown.

javatests/dagger/hilt/processor/internal/generatesrootinput/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ compiler_test(
3232
"//java/dagger/hilt/android/testing/compile",
3333
"//java/dagger/hilt/processor/internal:base_processor",
3434
"//java/dagger/hilt/processor/internal/generatesrootinput:generates_root_inputs",
35+
"//java/dagger/internal/codegen/extension",
3536
"//java/dagger/internal/codegen/xprocessing",
3637
"//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
3738
"//third_party/java/javapoet",

javatests/dagger/hilt/processor/internal/generatesrootinput/GeneratesRootInputProcessorTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
package dagger.hilt.processor.internal.generatesrootinput;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20+
import static dagger.internal.codegen.extension.DaggerStreams.toImmutableList;
2021

21-
import androidx.room.compiler.processing.XElement;
2222
import androidx.room.compiler.processing.XFiler.Mode;
2323
import androidx.room.compiler.processing.XProcessingEnv;
2424
import androidx.room.compiler.processing.XRoundEnv;
2525
import androidx.room.compiler.processing.util.Source;
26-
import com.google.common.truth.Correspondence;
2726
import com.squareup.javapoet.ClassName;
2827
import com.squareup.javapoet.JavaFile;
2928
import com.squareup.javapoet.TypeSpec;
@@ -43,7 +42,7 @@ public final class GeneratesRootInputProcessorTest {
4342
private static final int GENERATED_CLASSES = 5;
4443
private static final ClassName TEST_ANNOTATION = ClassName.get("test", "TestAnnotation");
4544

46-
private final List<XElement> elementsToWaitFor = new ArrayList<>();
45+
private final List<String> elementsToWaitFor = new ArrayList<>();
4746
private int generatedClasses = 0;
4847

4948
public final class TestAnnotationStep extends BaseProcessingStep {
@@ -57,7 +56,10 @@ public TestAnnotationStep(XProcessingEnv env) {
5756
@Override
5857
public void postProcess(XProcessingEnv processingEnv, XRoundEnv round) {
5958
if (generatedClasses > 0) {
60-
elementsToWaitFor.addAll(generatesRootInputs.getElementsToWaitFor(round));
59+
elementsToWaitFor.addAll(
60+
generatesRootInputs.getElementsToWaitFor(round).stream()
61+
.map(element -> XElements.asTypeElement(element).getQualifiedName())
62+
.collect(toImmutableList()));
6163
}
6264
if (generatedClasses < GENERATED_CLASSES) {
6365
TypeSpec typeSpec =
@@ -84,10 +86,6 @@ public void succeeds_ComponentProcessorWaitsForAnnotationsWithGeneratesRootInput
8486
subject -> {
8587
subject.hasErrorCount(0);
8688
assertThat(elementsToWaitFor)
87-
.comparingElementsUsing(
88-
Correspondence.<XElement, String>transforming(
89-
element -> XElements.asTypeElement(element).getQualifiedName(),
90-
"has qualified name of"))
9189
.containsExactly("foo.Foo0", "foo.Foo1", "foo.Foo2", "foo.Foo3", "foo.Foo4")
9290
.inOrder();
9391
elementsToWaitFor.clear();

javatests/dagger/internal/codegen/BindsMethodValidationTest.java

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static dagger.internal.codegen.DaggerModuleMethodSubject.Factory.assertThatModuleMethod;
2121
import static java.lang.annotation.RetentionPolicy.RUNTIME;
2222

23-
import androidx.room.compiler.processing.XProcessingEnv;
2423
import androidx.room.compiler.processing.util.Source;
2524
import com.google.common.collect.ImmutableList;
2625
import dagger.Module;
@@ -253,27 +252,21 @@ public void bindsMissingTypeInParameterHierarchy() {
253252
subject.hasErrorCount(2);
254253
break;
255254
}
256-
// TODO(b/248552462): Javac and KSP should match once this bug is fixed.
257-
boolean isJavac = CompilerTests.backend(subject) == XProcessingEnv.Backend.JAVAC;
258255
subject.hasErrorContaining(
259-
String.format(
260-
"ModuleProcessingStep was unable to process 'test.TestModule' because '%s' "
261-
+ "could not be resolved.",
262-
isJavac ? "MissingType" : "error.NonExistentClass"));
256+
"ModuleProcessingStep was unable to process 'test.TestModule' because "
257+
+ "'MissingType' could not be resolved.");
263258
subject.hasErrorContaining(
264-
String.format(
265-
"BindingMethodProcessingStep was unable to process"
266-
+ " 'bindObject(test.Child<java.lang.String>)' because '%1$s' could not "
267-
+ "be resolved."
268-
+ "\n "
269-
+ "\n Dependency trace:"
270-
+ "\n => element (INTERFACE): test.TestModule"
271-
+ "\n => element (METHOD): bindObject(test.Child<java.lang.String>)"
272-
+ "\n => element (PARAMETER): child"
273-
+ "\n => type (DECLARED parameter): test.Child<java.lang.String>"
274-
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
275-
+ "\n => type (ERROR supertype): %1$s",
276-
isJavac ? "MissingType" : "error.NonExistentClass"));
259+
"BindingMethodProcessingStep was unable to process "
260+
+ "'bindObject(test.Child<java.lang.String>)' because 'MissingType' could "
261+
+ "not be resolved."
262+
+ "\n "
263+
+ "\n Dependency trace:"
264+
+ "\n => element (INTERFACE): test.TestModule"
265+
+ "\n => element (METHOD): bindObject(test.Child<java.lang.String>)"
266+
+ "\n => element (PARAMETER): child"
267+
+ "\n => type (DECLARED parameter): test.Child<java.lang.String>"
268+
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
269+
+ "\n => type (ERROR supertype): MissingType");
277270
});
278271
}
279272

@@ -319,26 +312,19 @@ public void bindsMissingTypeInReturnTypeHierarchy() {
319312
subject.hasErrorCount(2);
320313
break;
321314
}
322-
// TODO(b/248552462): Javac and KSP should match once this bug is fixed.
323-
boolean isJavac = CompilerTests.backend(subject) == XProcessingEnv.Backend.JAVAC;
324315
subject.hasErrorContaining(
325-
String.format(
326-
"ModuleProcessingStep was unable to process 'test.TestModule' because '%s' "
327-
+ "could not be resolved.",
328-
isJavac ? "MissingType" : "error.NonExistentClass"));
316+
"ModuleProcessingStep was unable to process 'test.TestModule' because "
317+
+ "'MissingType' could not be resolved.");
329318
subject.hasErrorContaining(
330-
String.format(
331-
"BindingMethodProcessingStep was unable to process "
332-
+ "'bindChild(java.lang.String)' because '%1$s' could not be"
333-
+ " resolved."
334-
+ "\n "
335-
+ "\n Dependency trace:"
336-
+ "\n => element (INTERFACE): test.TestModule"
337-
+ "\n => element (METHOD): bindChild(java.lang.String)"
338-
+ "\n => type (DECLARED return type): test.Child<java.lang.String>"
339-
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
340-
+ "\n => type (ERROR supertype): %1$s",
341-
isJavac ? "MissingType" : "error.NonExistentClass"));
319+
"BindingMethodProcessingStep was unable to process 'bindChild(java.lang.String)' "
320+
+ "because 'MissingType' could not be resolved."
321+
+ "\n "
322+
+ "\n Dependency trace:"
323+
+ "\n => element (INTERFACE): test.TestModule"
324+
+ "\n => element (METHOD): bindChild(java.lang.String)"
325+
+ "\n => type (DECLARED return type): test.Child<java.lang.String>"
326+
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
327+
+ "\n => type (ERROR supertype): MissingType");
342328
});
343329
}
344330

0 commit comments

Comments
 (0)