Report rebuild reason in rebuild function
This commit is contained in:
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import java.io.File
|
||||
|
||||
interface ICReporter {
|
||||
fun report(message: ()->String)
|
||||
fun report(message: () -> String)
|
||||
|
||||
// used in Gradle plugin
|
||||
@Suppress("unused")
|
||||
|
||||
+6
-6
@@ -63,7 +63,9 @@ abstract class IncrementalCompilerRunner<
|
||||
assert(isICEnabled()) { "Incremental compilation is not enabled" }
|
||||
var caches = createCacheManager(args)
|
||||
|
||||
fun rebuild(): ExitCode {
|
||||
fun rebuild(reason: () -> String): ExitCode {
|
||||
reporter.report(reason)
|
||||
|
||||
caches.clean()
|
||||
dirtySourcesSinceLastTimeFile.delete()
|
||||
destinationDir(args).deleteRecursively()
|
||||
@@ -83,8 +85,7 @@ abstract class IncrementalCompilerRunner<
|
||||
compileIncrementally(args, caches, allKotlinSources, compilationMode, messageCollector)
|
||||
}
|
||||
is CompilationMode.Rebuild -> {
|
||||
reporter.report { "Non-incremental compilation will be performed: ${compilationMode.reason}" }
|
||||
rebuild()
|
||||
rebuild { "Non-incremental compilation will be performed: ${compilationMode.reason}" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,8 +95,7 @@ abstract class IncrementalCompilerRunner<
|
||||
}
|
||||
catch (e: Exception) {
|
||||
// todo: warn?
|
||||
reporter.report { "Possible cache corruption. Rebuilding. $e" }
|
||||
rebuild()
|
||||
rebuild { "Possible cache corruption. Rebuilding. $e" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ abstract class IncrementalCompilerRunner<
|
||||
|
||||
protected sealed class CompilationMode {
|
||||
class Incremental(val dirtyFiles: Set<File>) : CompilationMode()
|
||||
class Rebuild(getReason: ()->String = { "" }) : CompilationMode() {
|
||||
class Rebuild(getReason: () -> String = { "" }) : CompilationMode() {
|
||||
val reason: String by lazy(getReason)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ fun makeIncrementally(
|
||||
}
|
||||
|
||||
object EmptyICReporter : ICReporter {
|
||||
override fun report(message: ()->String) {
|
||||
override fun report(message: () -> String) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class TestICReporter : ICReporter {
|
||||
var exitCode: ExitCode = ExitCode.OK
|
||||
private set
|
||||
|
||||
override fun report(message: ()->String) {
|
||||
override fun report(message: () -> String) {
|
||||
}
|
||||
|
||||
override fun reportCompileIteration(sourceFiles: Collection<File>, exitCode: ExitCode) {
|
||||
|
||||
@@ -789,7 +789,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
}
|
||||
|
||||
private class JpsICReporter : ICReporter {
|
||||
override fun report(message: ()->String) {
|
||||
override fun report(message: () -> String) {
|
||||
if (KotlinBuilder.LOG.isDebugEnabled) {
|
||||
KotlinBuilder.LOG.debug(message())
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.io.File
|
||||
internal class GradleICReporter(private val projectRootFile: File) : ICReporter {
|
||||
private val log = Logging.getLogger(GradleICReporter::class.java)
|
||||
|
||||
override fun report(message: ()->String) {
|
||||
override fun report(message: () -> String) {
|
||||
log.kotlinDebug(message)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user