Replace Gradle logger with ICReporter
This commit is contained in:
+3
-4
@@ -30,8 +30,7 @@ import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
internal class ChangedJavaFilesProcessor {
|
||||
private val log = Logging.getLogger(this.javaClass.simpleName)
|
||||
internal class ChangedJavaFilesProcessor(private val reporter: ICReporter) {
|
||||
private val allSymbols = HashSet<LookupSymbol>()
|
||||
private val javaLang = JavaLanguage.INSTANCE
|
||||
private val psiFileFactory: PsiFileFactory by lazy {
|
||||
@@ -50,7 +49,7 @@ internal class ChangedJavaFilesProcessor {
|
||||
val removedJava = filesDiff.removed.filter(File::isJavaFile)
|
||||
|
||||
if (removedJava.any()) {
|
||||
log.kotlinDebug { "Some java files are removed: [${removedJava.joinToString()}]" }
|
||||
reporter.report { "Some java files are removed: [${removedJava.joinToString()}]" }
|
||||
return ChangesEither.Unknown()
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ internal class ChangedJavaFilesProcessor {
|
||||
|
||||
val psiFile = javaFile.psiFile()
|
||||
if (psiFile !is PsiJavaFile) {
|
||||
log.kotlinDebug { "Expected PsiJavaFile, got ${psiFile?.javaClass}" }
|
||||
reporter.report { "Expected PsiJavaFile, got ${psiFile?.javaClass}" }
|
||||
return ChangesEither.Unknown()
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -25,15 +25,18 @@ import org.jetbrains.kotlin.incremental.storage.StringCollectionExternalizer
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import java.io.File
|
||||
|
||||
internal class GradleIncrementalCacheImpl(targetDataRoot: File, targetOutputDir: File?, target: TargetId) : IncrementalCacheImpl<TargetId>(targetDataRoot, targetOutputDir, target) {
|
||||
internal class GradleIncrementalCacheImpl(
|
||||
targetDataRoot: File,
|
||||
targetOutputDir: File?,
|
||||
target: TargetId,
|
||||
private val reporter: ICReporter
|
||||
) : IncrementalCacheImpl<TargetId>(targetDataRoot, targetOutputDir, target) {
|
||||
companion object {
|
||||
private val SOURCES_TO_CLASSFILES = "sources-to-classfiles"
|
||||
private val GENERATED_SOURCE_SNAPSHOTS = "generated-source-snapshot"
|
||||
private val SOURCE_SNAPSHOTS = "source-snapshot"
|
||||
}
|
||||
|
||||
private val log = org.gradle.api.logging.Logging.getLogger(this.javaClass)
|
||||
|
||||
internal val sourceToClassfilesMap = registerMap(SourceToClassfilesMap(SOURCES_TO_CLASSFILES.storageFile))
|
||||
internal val generatedSourceSnapshotMap = registerMap(FileSnapshotMap(GENERATED_SOURCE_SNAPSHOTS.storageFile))
|
||||
internal val sourceSnapshotMap = registerMap(FileSnapshotMap(SOURCE_SNAPSHOTS.storageFile))
|
||||
@@ -60,7 +63,7 @@ internal class GradleIncrementalCacheImpl(targetDataRoot: File, targetOutputDir:
|
||||
// TODO: do it in the code that uses cache, since cache should not generally delete anything outside of it!
|
||||
// but for a moment it is an easiest solution to implement
|
||||
get(file).forEach {
|
||||
log.kotlinDebug { "Deleting $it on clearing cache for $file" }
|
||||
reporter.report { "Deleting $it on clearing cache for $file" }
|
||||
it.delete()
|
||||
}
|
||||
storage.remove(file.absolutePath)
|
||||
|
||||
+4
-2
@@ -22,7 +22,8 @@ import java.io.File
|
||||
internal class IncrementalCachesManager (
|
||||
private val targetId: TargetId,
|
||||
private val cacheDirectory: File,
|
||||
private val outputDir: File
|
||||
private val outputDir: File,
|
||||
private val reporter: ICReporter
|
||||
) {
|
||||
private val incrementalCacheDir = File(cacheDirectory, "increCache.${targetId.name}")
|
||||
private val lookupCacheDir = File(cacheDirectory, "lookups")
|
||||
@@ -32,7 +33,8 @@ internal class IncrementalCachesManager (
|
||||
val incrementalCache: GradleIncrementalCacheImpl
|
||||
get() {
|
||||
if (incrementalCacheField == null) {
|
||||
incrementalCacheField = GradleIncrementalCacheImpl(targetDataRoot = incrementalCacheDir.apply { mkdirs() }, targetOutputDir = outputDir, target = targetId)
|
||||
val targetDataRoot = incrementalCacheDir.apply { mkdirs() }
|
||||
incrementalCacheField = GradleIncrementalCacheImpl(targetDataRoot, outputDir, targetId, reporter)
|
||||
}
|
||||
|
||||
return incrementalCacheField!!
|
||||
|
||||
+4
-4
@@ -112,7 +112,7 @@ internal class IncrementalJvmCompilerRunner(
|
||||
getChangedFiles: (IncrementalCachesManager)->ChangedFiles
|
||||
): ExitCode {
|
||||
val targetId = TargetId(name = args.moduleName, type = "java-production")
|
||||
var caches = IncrementalCachesManager(targetId, cacheDirectory, File(args.destination))
|
||||
var caches = IncrementalCachesManager(targetId, cacheDirectory, File(args.destination), reporter)
|
||||
|
||||
fun onError(e: Exception): ExitCode {
|
||||
caches.clean()
|
||||
@@ -121,13 +121,13 @@ internal class IncrementalJvmCompilerRunner(
|
||||
// todo: warn?
|
||||
reporter.report { "Possible cache corruption. Rebuilding. $e" }
|
||||
// try to rebuild
|
||||
val javaFilesProcessor = ChangedJavaFilesProcessor()
|
||||
caches = IncrementalCachesManager(targetId, cacheDirectory, args.destinationAsFile)
|
||||
val javaFilesProcessor = ChangedJavaFilesProcessor(reporter)
|
||||
caches = IncrementalCachesManager(targetId, cacheDirectory, args.destinationAsFile, reporter)
|
||||
return compileIncrementally(args, caches, javaFilesProcessor, allKotlinSources, targetId, CompilationMode.Rebuild, messageCollector)
|
||||
}
|
||||
|
||||
return try {
|
||||
val javaFilesProcessor = ChangedJavaFilesProcessor()
|
||||
val javaFilesProcessor = ChangedJavaFilesProcessor(reporter)
|
||||
val changedFiles = getChangedFiles(caches)
|
||||
val compilationMode = calculateSourcesToCompile(javaFilesProcessor, caches, changedFiles, args)
|
||||
compileIncrementally(args, caches, javaFilesProcessor, allKotlinSources, targetId, compilationMode, messageCollector)
|
||||
|
||||
Reference in New Issue
Block a user