-
Notifications
You must be signed in to change notification settings - Fork 14
Cleanup old sources between compilations #273
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
Conversation
This is required since KSP accepts a list of source directories while Kotlin accepts a list of source files. This means that if you compile multiple times, removing a source file between, KSP will still process the removed files.
@@ -9,7 +9,7 @@ import org.intellij.lang.annotations.Language | |||
* A source file for the [KotlinCompilation] | |||
*/ | |||
abstract class SourceFile { | |||
internal abstract fun writeIfNeeded(dir: File): File | |||
internal abstract fun writeTo(dir: File): File |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured that renaming this makes sense since it will always write the contents now. Can revert though.
@@ -50,12 +50,13 @@ abstract class SourceFile { | |||
/** | |||
* Compile an existing source file | |||
*/ | |||
@Deprecated("This will not work reliably with KSP, use `new` instead") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since KSP2 accepts source directories KCT can't allow arbitrary files now.
@@ -117,6 +117,12 @@ var KotlinCompilation.kspLoggingLevels: Set<CompilerMessageSeverity> | |||
tool.loggingLevels = value | |||
} | |||
|
|||
@ExperimentalCompilerApi | |||
val JvmCompilationResult.sourcesGeneratedBySymbolProcessor: Sequence<File> | |||
get() = outputDirectory.parentFile.resolve("ksp/sources") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled about this solution but other solutions require exposing the compilation which doesn't seem ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the round matter here? KSP does output files by round in some circumstances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you have a result all rounds should be over, so this should include all files. But perhaps I misunderstand your question?
@@ -117,6 +117,12 @@ var KotlinCompilation.kspLoggingLevels: Set<CompilerMessageSeverity> | |||
tool.loggingLevels = value | |||
} | |||
|
|||
@ExperimentalCompilerApi | |||
val JvmCompilationResult.sourcesGeneratedBySymbolProcessor: Sequence<File> | |||
get() = outputDirectory.parentFile.resolve("ksp/sources") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the round matter here? KSP does output files by round in some circumstances
This is required since KSP accepts a list of source directories while Kotlin accepts a list of source files. This means that if you compile multiple times, removing a source file between, KSP will still process the removed files.