-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
companion object { | ||
/** | ||
|
@@ -34,7 +34,7 @@ abstract class SourceFile { | |
* Create a new source file for the compilation when the compilation is run | ||
*/ | ||
fun new(name: String, contents: String) = object : SourceFile() { | ||
override fun writeIfNeeded(dir: File): File { | ||
override fun writeTo(dir: File): File { | ||
val file = dir.resolve(name) | ||
file.parentFile.mkdirs() | ||
file.createNewFile() | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Since KSP2 accepts source directories KCT can't allow arbitrary files now. |
||
fun fromPath(path: File) = object : SourceFile() { | ||
init { | ||
require(path.isFile) | ||
} | ||
|
||
override fun writeIfNeeded(dir: File): File = path | ||
override fun writeTo(dir: File): File = path | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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 commentThe 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? |
||
.walkTopDown() | ||
.filter { it.isFile } | ||
|
||
@OptIn(ExperimentalCompilerApi::class) | ||
internal val KotlinCompilation.kspJavaSourceDir: File | ||
get() = kspSourcesDir.resolve("java") | ||
|
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.