Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade XProcessing jars. #4585

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ KOTLIN_VERSION = "2.0.21"

KSP_VERSION = KOTLIN_VERSION + "-1.0.28"

# XProcessing testing uses the embeddable Kotlin version. Ideally, this would be
# the same as KOTLIN_VERSION, but XProcessing testing requires 2.1.0 and Bazel
# doesn't support 2.1.0 yet. See https://github.com/bazelbuild/rules_kotlin/issues/1176.
EMBEDDABLE_KOTLIN_VERSION = "2.1.0"

EMBEDDABLE_KSP_VERSION = EMBEDDABLE_KOTLIN_VERSION + "-1.0.28"

MAVEN_VERSION = "3.3.3"

maven_install(
Expand Down Expand Up @@ -251,7 +258,6 @@ maven_install(
"com.google.devtools.ksp:symbol-processing:%s" % KSP_VERSION,
"com.google.devtools.ksp:symbol-processing-api:%s" % KSP_VERSION,
"com.google.devtools.ksp:symbol-processing-common-deps:%s" % KSP_VERSION,
"com.google.devtools.ksp:symbol-processing-aa-embeddable:%s" % KSP_VERSION,
"com.google.errorprone:error_prone_annotation:%s" % ERROR_PRONE_VERSION,
"com.google.errorprone:error_prone_annotations:%s" % ERROR_PRONE_VERSION,
"com.google.errorprone:error_prone_check_api:%s" % ERROR_PRONE_VERSION,
Expand Down Expand Up @@ -294,9 +300,6 @@ maven_install(
"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,
"org.jetbrains.kotlin:kotlin-daemon-embeddable:%s" % KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-metadata-jvm:%s" % KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-stdlib:%s" % KOTLIN_VERSION,
"org.jspecify:jspecify:1.0.0",
Expand All @@ -314,3 +317,20 @@ maven_install(
"https://maven.google.com",
],
)

maven_install(
name = "kotlin_embeddable",
artifacts = [
"com.google.devtools.ksp:symbol-processing:%s" % EMBEDDABLE_KSP_VERSION,
"com.google.devtools.ksp:symbol-processing-aa-embeddable:%s" % EMBEDDABLE_KSP_VERSION,
"org.jetbrains.kotlin:kotlin-annotation-processing-embeddable:%s" % EMBEDDABLE_KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-compiler-embeddable:%s" % EMBEDDABLE_KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-daemon-embeddable:%s" % EMBEDDABLE_KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-metadata-jvm:%s" % EMBEDDABLE_KOTLIN_VERSION,
"org.jetbrains.kotlin:kotlin-stdlib:%s" % EMBEDDABLE_KOTLIN_VERSION,
],
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
)
12 changes: 6 additions & 6 deletions java/dagger/internal/codegen/xprocessing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ java_library(
testonly = 1,
exports = [
":xprocessing-testing-lib",
"@maven//:com_google_devtools_ksp_symbol_processing",
"@maven//:com_google_devtools_ksp_symbol_processing_aa_embeddable",
"@maven//:com_google_devtools_ksp_symbol_processing_common_deps",
"@maven//:org_jetbrains_kotlin_kotlin_annotation_processing_embeddable",
"@maven//:org_jetbrains_kotlin_kotlin_compiler_embeddable",
"@maven//:org_jetbrains_kotlin_kotlin_daemon_embeddable",
"@kotlin_embeddable//:com_google_devtools_ksp_symbol_processing",
"@kotlin_embeddable//:com_google_devtools_ksp_symbol_processing_aa_embeddable",
"@kotlin_embeddable//:com_google_devtools_ksp_symbol_processing_common_deps",
"@kotlin_embeddable//:org_jetbrains_kotlin_kotlin_annotation_processing_embeddable",
"@kotlin_embeddable//:org_jetbrains_kotlin_kotlin_compiler_embeddable",
"@kotlin_embeddable//:org_jetbrains_kotlin_kotlin_daemon_embeddable",
],
)

Expand Down
Binary file modified java/dagger/internal/codegen/xprocessing/xprocessing-testing.jar
Binary file not shown.
Binary file modified java/dagger/internal/codegen/xprocessing/xprocessing.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ compiler_test(
"//java/dagger/hilt/android/testing/compile",
"//java/dagger/hilt/processor/internal:base_processor",
"//java/dagger/hilt/processor/internal/generatesrootinput:generates_root_inputs",
"//java/dagger/internal/codegen/extension",
"//java/dagger/internal/codegen/xprocessing",
"//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
"//third_party/java/javapoet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
package dagger.hilt.processor.internal.generatesrootinput;

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

import androidx.room.compiler.processing.XElement;
import androidx.room.compiler.processing.XFiler.Mode;
import androidx.room.compiler.processing.XProcessingEnv;
import androidx.room.compiler.processing.XRoundEnv;
import androidx.room.compiler.processing.util.Source;
import com.google.common.truth.Correspondence;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.TypeSpec;
Expand All @@ -43,7 +42,7 @@ public final class GeneratesRootInputProcessorTest {
private static final int GENERATED_CLASSES = 5;
private static final ClassName TEST_ANNOTATION = ClassName.get("test", "TestAnnotation");

private final List<XElement> elementsToWaitFor = new ArrayList<>();
private final List<String> elementsToWaitFor = new ArrayList<>();
private int generatedClasses = 0;

public final class TestAnnotationStep extends BaseProcessingStep {
Expand All @@ -57,7 +56,10 @@ public TestAnnotationStep(XProcessingEnv env) {
@Override
public void postProcess(XProcessingEnv processingEnv, XRoundEnv round) {
if (generatedClasses > 0) {
elementsToWaitFor.addAll(generatesRootInputs.getElementsToWaitFor(round));
elementsToWaitFor.addAll(
generatesRootInputs.getElementsToWaitFor(round).stream()
.map(element -> XElements.asTypeElement(element).getQualifiedName())
.collect(toImmutableList()));
}
if (generatedClasses < GENERATED_CLASSES) {
TypeSpec typeSpec =
Expand All @@ -84,10 +86,6 @@ public void succeeds_ComponentProcessorWaitsForAnnotationsWithGeneratesRootInput
subject -> {
subject.hasErrorCount(0);
assertThat(elementsToWaitFor)
.comparingElementsUsing(
Correspondence.<XElement, String>transforming(
element -> XElements.asTypeElement(element).getQualifiedName(),
"has qualified name of"))
.containsExactly("foo.Foo0", "foo.Foo1", "foo.Foo2", "foo.Foo3", "foo.Foo4")
.inOrder();
elementsToWaitFor.clear();
Expand Down
62 changes: 24 additions & 38 deletions javatests/dagger/internal/codegen/BindsMethodValidationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static dagger.internal.codegen.DaggerModuleMethodSubject.Factory.assertThatModuleMethod;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import androidx.room.compiler.processing.XProcessingEnv;
import androidx.room.compiler.processing.util.Source;
import com.google.common.collect.ImmutableList;
import dagger.Module;
Expand Down Expand Up @@ -253,27 +252,21 @@ public void bindsMissingTypeInParameterHierarchy() {
subject.hasErrorCount(2);
break;
}
// TODO(b/248552462): Javac and KSP should match once this bug is fixed.
boolean isJavac = CompilerTests.backend(subject) == XProcessingEnv.Backend.JAVAC;
subject.hasErrorContaining(
String.format(
"ModuleProcessingStep was unable to process 'test.TestModule' because '%s' "
+ "could not be resolved.",
isJavac ? "MissingType" : "error.NonExistentClass"));
"ModuleProcessingStep was unable to process 'test.TestModule' because "
+ "'MissingType' could not be resolved.");
subject.hasErrorContaining(
String.format(
"BindingMethodProcessingStep was unable to process"
+ " 'bindObject(test.Child<java.lang.String>)' because '%1$s' could not "
+ "be resolved."
+ "\n "
+ "\n Dependency trace:"
+ "\n => element (INTERFACE): test.TestModule"
+ "\n => element (METHOD): bindObject(test.Child<java.lang.String>)"
+ "\n => element (PARAMETER): child"
+ "\n => type (DECLARED parameter): test.Child<java.lang.String>"
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
+ "\n => type (ERROR supertype): %1$s",
isJavac ? "MissingType" : "error.NonExistentClass"));
"BindingMethodProcessingStep was unable to process "
+ "'bindObject(test.Child<java.lang.String>)' because 'MissingType' could "
+ "not be resolved."
+ "\n "
+ "\n Dependency trace:"
+ "\n => element (INTERFACE): test.TestModule"
+ "\n => element (METHOD): bindObject(test.Child<java.lang.String>)"
+ "\n => element (PARAMETER): child"
+ "\n => type (DECLARED parameter): test.Child<java.lang.String>"
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
+ "\n => type (ERROR supertype): MissingType");
});
}

Expand Down Expand Up @@ -319,26 +312,19 @@ public void bindsMissingTypeInReturnTypeHierarchy() {
subject.hasErrorCount(2);
break;
}
// TODO(b/248552462): Javac and KSP should match once this bug is fixed.
boolean isJavac = CompilerTests.backend(subject) == XProcessingEnv.Backend.JAVAC;
subject.hasErrorContaining(
String.format(
"ModuleProcessingStep was unable to process 'test.TestModule' because '%s' "
+ "could not be resolved.",
isJavac ? "MissingType" : "error.NonExistentClass"));
"ModuleProcessingStep was unable to process 'test.TestModule' because "
+ "'MissingType' could not be resolved.");
subject.hasErrorContaining(
String.format(
"BindingMethodProcessingStep was unable to process "
+ "'bindChild(java.lang.String)' because '%1$s' could not be"
+ " resolved."
+ "\n "
+ "\n Dependency trace:"
+ "\n => element (INTERFACE): test.TestModule"
+ "\n => element (METHOD): bindChild(java.lang.String)"
+ "\n => type (DECLARED return type): test.Child<java.lang.String>"
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
+ "\n => type (ERROR supertype): %1$s",
isJavac ? "MissingType" : "error.NonExistentClass"));
"BindingMethodProcessingStep was unable to process 'bindChild(java.lang.String)' "
+ "because 'MissingType' could not be resolved."
+ "\n "
+ "\n Dependency trace:"
+ "\n => element (INTERFACE): test.TestModule"
+ "\n => element (METHOD): bindChild(java.lang.String)"
+ "\n => type (DECLARED return type): test.Child<java.lang.String>"
+ "\n => type (DECLARED supertype): test.Parent<java.lang.String>"
+ "\n => type (ERROR supertype): MissingType");
});
}

Expand Down
Loading
Loading