Report rebuild reason in rebuild function

This commit is contained in:
Nikolay Krasko
2017-11-07 16:19:32 +03:00
parent 97c1e58149
commit 643f771c24
6 changed files with 11 additions and 11 deletions
@@ -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")
@@ -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)
}
}
@@ -67,7 +67,7 @@ fun makeIncrementally(
}
object EmptyICReporter : ICReporter {
override fun report(message: ()->String) {
override fun report(message: () -> String) {
}
}
@@ -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())
}
@@ -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)
}