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

KSP up-to-date after changing processor code #1308

Closed
ansman opened this issue Feb 7, 2023 · 2 comments · Fixed by #1310
Closed

KSP up-to-date after changing processor code #1308

ansman opened this issue Feb 7, 2023 · 2 comments · Fixed by #1310
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ansman
Copy link
Contributor

ansman commented Feb 7, 2023

I'm working on a small example project where I have 3 Gradle modules:

  • api - Contains my annotations
  • compiler - Contains my Symbol Processor (and an annotation processor)
  • test - Contains some test code

When I make an ABI compatible change in my compiler, kspKotlin is still considered up-to-date and the updated code won't be reflected. KAPT correctly runs again:

$ ./gradlew :test:assemble --console plain
Configuration cache is an incubating feature.
Reusing configuration cache.
> Task :compiler:processResources NO-SOURCE
> Task :api:processResources NO-SOURCE
> Task :api:compileKotlin UP-TO-DATE
> Task :api:compileJava NO-SOURCE
> Task :api:classes UP-TO-DATE
> Task :api:jar UP-TO-DATE
> Task :api:inspectClassesForKotlinIC UP-TO-DATE
> Task :compiler:kaptGenerateStubsKotlin
> Task :compiler:kaptKotlin UP-TO-DATE
> Task :compiler:compileKotlin
> Task :compiler:compileJava NO-SOURCE
> Task :compiler:classes UP-TO-DATE
> Task :compiler:jar
> Task :compiler:inspectClassesForKotlinIC
> Task :test:kspKotlin UP-TO-DATE
> Task :test:processResources NO-SOURCE
> Task :test:kaptGenerateStubsKotlin UP-TO-DATE
> Task :test:kaptKotlin
> Task :test:compileKotlin
> Task :test:compileJava NO-SOURCE
> Task :test:classes UP-TO-DATE
> Task :test:jar
> Task :test:assemble
> Task :test:inspectClassesForKotlinIC

BUILD SUCCESSFUL in 816ms
14 actionable tasks: 8 executed, 6 up-to-date
Configuration cache entry reused.

Notice that kspKotlin is considered UP-TO-DATE here while kaptKotlin runs again.

Here you can see the --info output between KSP and KAPT:

> Task :test:kaptKotlin
Transforming api.jar with StructureTransformAction
Transforming kotlin-stdlib-jdk8-1.8.10.jar with StructureTransformAction
Transforming kotlin-stdlib-jdk7-1.8.10.jar with StructureTransformAction
Transforming kotlin-stdlib-1.8.10.jar with StructureTransformAction
Transforming kotlin-stdlib-common-1.8.10.jar with StructureTransformAction
Transforming annotations-13.0.jar with StructureTransformAction
file or directory '/Users/nicklas/Repositories/example-processor/test/src/main/java', not found
file or directory '/Users/nicklas/Repositories/example-processor/test/src/generatedByKspKotlin/kotlin', not found
file or directory '/Users/nicklas/Repositories/example-processor/test/build/generated/ksp/main/java', not found
Caching disabled for task ':test:kaptKotlin' because:
  Build cache is disabled
Task ':test:kaptKotlin' is not up-to-date because:
  Input property 'kaptClasspath' file /Users/nicklas/Repositories/example-processor/compiler/build/libs/compiler.jar has changed.
The input changes require a full rebuild for incremental task ':test:kaptKotlin'.
Running kapt annotation processing using the Gradle Worker API
Using workers NONE isolation mode to run kapt

> Task :test:kspKotlin UP-TO-DATE
file or directory '/Users/nicklas/Repositories/example-processor/test/src/main/java', not found
file or directory '/Users/nicklas/Repositories/example-processor/test/src/main/java', not found
Caching disabled for task ':test:kspKotlin' because:
  Build cache is disabled
Skipping task ':test:kspKotlin' as it is up-to-date.
Resolve mutations for :test:kaptGenerateStubsKotlin (Thread[Execution worker,5,main]) started.
:test:kaptGenerateStubsKotlin (Thread[Execution worker,5,main]) started.

The change I'm making is changing a string inside the compiler module.
This is using Gradle 7.6, Kotlin 1.8.10, KSP 1.8.10-1.0.9 on Java 18.

I'll try to add a small repro later.

@ting-yuan ting-yuan self-assigned this Feb 7, 2023
@ting-yuan ting-yuan added this to the 1.0.10 milestone Feb 7, 2023
@ting-yuan ting-yuan added the bug Something isn't working label Feb 7, 2023
@ansman
Copy link
Contributor Author

ansman commented Feb 8, 2023

I've attached a test project: ksp-incremental-issue.zip

It contains the following modules:

  • compiler - A module with a dummy annotation processor and a dummy symbol processor.
  • app - A module with an annotated file.
  • test - A module with a test case that shows the issue.

Just run ./gradlew :test:check to run the test.

The test does the following:

  1. Copies the compiler and app modules to a temporary directory
  2. Runs :app:assemble
  3. Checks that the tasks ran. It checks both the kaptKotlin and kspKotlin tasks for parity
  4. Runs :app:assemble again
  5. Checks that the tasks are up to date
  6. Change the compiler to generate slightly different code
  7. Runs :app:assemble again
  8. Checks that the tasks ran

Step 9 fails as the kspKotlin task is up-to-date

@ting-yuan
Copy link
Collaborator

Thanks for reporting and the test case! I've verified the commit with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants