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

Incremental processing doesn't copy backed up files after KSP finishes #1231

Closed
LukasAnda opened this issue Dec 7, 2022 · 6 comments
Closed
Assignees
Milestone

Comments

@LukasAnda
Copy link

Prerequisites:

  • Annotation that is used by multiple classes

Steps to reproduce:

  1. Clean project + rebuild project
  2. Change one of the files containing annotation
  3. Make project

Expected results:
All non-dirty files should be where they were

Actual results:
Only changed files get processed and non-dirty files get deleted

Ksp version: 1.7.20-1.0.7

@neetopia
Copy link
Contributor

neetopia commented Dec 7, 2022

is this your reproduce repo?
https://github.com/LukasAnda/NaviKator

@LukasAnda
Copy link
Author

It needs to be updated with reproducible example, I'll do that tomorrow

@LukasAnda
Copy link
Author

@neetopia yes, that is the repo with reproducible issue. Right now in app's build.gradle there is a fix with a gradle task that copies the remaining files.

Steps to reproduce the bug:

  1. In app's build.gradle comment out the afterEvaluate block (lines 52 to 68)
  2. Clean build + rebuild
  3. Change a line (for example add a newline) in HomeViewModel
  4. Make project (The hammer icon)
  5. See the compilation fails.

Expected result:
The compilation should work

How to fix this:

  1. Enable task to fix the issue in app's build.gradle once again
  2. Clean build + rebuild
  3. Any changes + Make will result in compilation working

Please note that the project should be opened in Android Studio. I've used AS Electric Eel 2022.1.1 Beta 5

@LukasAnda LukasAnda changed the title Backed up files not copied after compilation is finished Incremental processing doesn't copy backed up files after KSP finishes Dec 8, 2022
@huanglongyu
Copy link

I encountered the same problem, but fortunately @LukasAnda was able to provide a solution. I am looking forward to the official resolution.

@ting-yuan ting-yuan added this to the 1.0.9 milestone Jan 5, 2023
@ting-yuan ting-yuan self-assigned this Jan 5, 2023
@ting-yuan
Copy link
Collaborator

Hi @LukasAnda, KSP needs processors' help to associate inputs and outputs so as to maintain the clean outputs. In the given sample project, all the outputs are not associated to any (clean) sources, and therefore they are orphaned and got purged.

Can you try to supply originatingKSFiles to FileSpec.writeTo?

E.g.,

// NavigationRouteGenerator.kt
fileSpec.writeTo(
    codeGenerator,
    aggregating = false,
    originatingKSFiles = listOf(viewModel.containingFile!!, content.containingFile!!)
)
// NavigationRouteVisitor.kt
fileSpec.writeTo(
    codeGenerator,
    aggregating = true,
    originatingKSFiles = listOf(classDeclaration.containingFile!!)
)

@ting-yuan ting-yuan closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2023
@huanglongyu
Copy link

it works in my case

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

No branches or pull requests

4 participants