Skip to content

Preserve all originating elements for KSP incremental processing - #5370

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1023204044
Nov 20, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1023204044

Conversation

@copybara-service

Copy link
Copy Markdown

Preserve all originating elements for KSP incremental processing

XTypeSpecs.Builder.addOriginatingElement() currently overwrites the previous element.

Components with multiple generated modules therefore lose input dependencies needed by KSP incremental processing. Editing only the component can make the next build fail because an unchanged generated module is missing.

The fix keeps all originating elements.

Fixes #5363

This was triggered when TypeSpec was migrated to XTypeSpec in 7c4622d. Javapoet's addOriginatingElement correctly tracks elements as a list.

https://github.com/square/javapoet/blob/b9017a9503b76e11b4ad4c1a9f050e2d29112cb0/src/main/java/com/squareup/javapoet/TypeSpec.java#L429

Validation:

  • The new Gradle regression fails with the unpatched compiler on its second build: ActivityModule_Activity could not be resolved. It passes with this patch using Kotlin 2.3.21 and KSP 2.3.7.
  • Both tests in IncrementalProcessingTest pass against the patched local snapshot.
  • Bazel tests pass: XTypeSpecsTest, XCodeBlocksTest, XMethodElementsTest, ComponentProcessorTest, ComponentShardTest, and KspComponentProcessorTest.
  • git diff --check passes.

Fixes #5360

RELNOTES=N/A
FUTURE_COPYBARA_INTEGRATE_REVIEW=#5360 from nolanpollack-stripe:fix-originating-elements 8b39069

`XTypeSpecs.Builder.addOriginatingElement()` currently overwrites the previous element.

Components with multiple generated modules therefore lose input dependencies needed by KSP incremental processing. Editing only the component can make the next build fail because an unchanged generated module is missing.

The fix keeps all originating elements.

Fixes #5363

This was triggered when `TypeSpec` was migrated to `XTypeSpec` in  7c4622d. Javapoet's `addOriginatingElement` correctly tracks elements as a list.

https://github.com/square/javapoet/blob/b9017a9503b76e11b4ad4c1a9f050e2d29112cb0/src/main/java/com/squareup/javapoet/TypeSpec.java#L429

Validation:
- The new Gradle regression fails with the unpatched compiler on its second build: `ActivityModule_Activity` could not be resolved. It passes with this patch using Kotlin 2.3.21 and KSP 2.3.7.
- Both tests in `IncrementalProcessingTest` pass against the patched local snapshot.
- Bazel tests pass: `XTypeSpecsTest`, `XCodeBlocksTest`, `XMethodElementsTest`, `ComponentProcessorTest`, `ComponentShardTest`, and `KspComponentProcessorTest`.
- `git diff --check` passes.

Fixes #5360

RELNOTES=N/A
COPYBARA_INTEGRATE_REVIEW=#5360 from nolanpollack-stripe:fix-originating-elements 8b39069
PiperOrigin-RevId: 1026714370
@copybara-service
copybara-service Bot merged commit 6949f0b into master Nov 20, 2026
3 checks passed
@copybara-service
copybara-service Bot deleted the test_1023204044 branch November 20, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KSP incremental build fails to resolve generated modules when multiple @ContributesAndroidInjector modules are included

1 participant