Refactoring: delegate IC files management to IncrementalJvmCompilerRunner
This commit is contained in:
+10
-3
@@ -24,17 +24,15 @@ import java.io.File
|
||||
import java.util.*
|
||||
|
||||
internal class IncrementalJvmCompilerRunner(
|
||||
workingDir: File,
|
||||
classpath: Iterable<File>,
|
||||
private var kaptAnnotationsFileUpdater: AnnotationFileUpdater?,
|
||||
private val artifactDifferenceRegistryProvider: ArtifactDifferenceRegistryProvider?,
|
||||
private val sourceAnnotationsRegistry: SourceAnnotationsRegistry?,
|
||||
private val javaSourceRoots: Set<File>,
|
||||
private val destinationDir: File,
|
||||
private val dirtySourcesSinceLastTimeFile: File,
|
||||
private val lastBuildInfoFile: File,
|
||||
private val kapt2GeneratedSourcesDir: File,
|
||||
private val artifactFile: File?,
|
||||
private val cacheDirectory: File,
|
||||
private val cacheVersions: List<CacheVersion>,
|
||||
private val reporter: IncReporter
|
||||
) {
|
||||
@@ -42,6 +40,9 @@ internal class IncrementalJvmCompilerRunner(
|
||||
private set
|
||||
private val classpath = classpath.toMutableList()
|
||||
private val additionalClasspath = LinkedHashSet<File>()
|
||||
private val cacheDirectory = File(workingDir, CACHES_DIR_NAME)
|
||||
private val dirtySourcesSinceLastTimeFile = File(workingDir, DIRTY_SOURCES_FILE_NAME)
|
||||
private val lastBuildInfoFile = File(workingDir, LAST_BUILD_INFO_FILE_NAME)
|
||||
|
||||
fun compile(allKotlinSources: List<File>, changedFiles: ChangedFiles, args: K2JVMCompilerArguments, messageCollector: MessageCollector): ExitCode {
|
||||
val outputDir = destinationDir
|
||||
@@ -406,4 +407,10 @@ internal class IncrementalJvmCompilerRunner(
|
||||
delegate.report(severity, message, location)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val CACHES_DIR_NAME = "caches"
|
||||
const val DIRTY_SOURCES_FILE_NAME = "dirty-sources.txt"
|
||||
const val LAST_BUILD_INFO_FILE_NAME = "last-build.bin"
|
||||
}
|
||||
}
|
||||
+3
-10
@@ -42,9 +42,6 @@ import kotlin.properties.Delegates
|
||||
|
||||
const val ANNOTATIONS_PLUGIN_NAME = "org.jetbrains.kotlin.kapt"
|
||||
const val KOTLIN_BUILD_DIR_NAME = "kotlin"
|
||||
const val CACHES_DIR_NAME = "caches"
|
||||
const val DIRTY_SOURCES_FILE_NAME = "dirty-sources.txt"
|
||||
const val LAST_BUILD_INFO_FILE_NAME = "last-build.bin"
|
||||
const val USING_EXPERIMENTAL_INCREMENTAL_MESSAGE = "Using experimental kotlin incremental compilation"
|
||||
|
||||
abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractCompile() {
|
||||
@@ -107,9 +104,6 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
|
||||
internal val taskBuildDirectory: File
|
||||
get() = File(File(project.buildDir, KOTLIN_BUILD_DIR_NAME), name).apply { mkdirs() }
|
||||
private val cacheDirectory: File by lazy { File(taskBuildDirectory, CACHES_DIR_NAME) }
|
||||
private val dirtySourcesSinceLastTimeFile: File by lazy { File(taskBuildDirectory, DIRTY_SOURCES_FILE_NAME) }
|
||||
private val lastBuildInfoFile: File by lazy { File(taskBuildDirectory, LAST_BUILD_INFO_FILE_NAME) }
|
||||
private val cacheVersions by lazy {
|
||||
listOf(normalCacheVersion(taskBuildDirectory),
|
||||
experimentalCacheVersion(taskBuildDirectory),
|
||||
@@ -178,17 +172,16 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
||||
logger.warn(USING_EXPERIMENTAL_INCREMENTAL_MESSAGE)
|
||||
val reporter = GradleIncReporter(project.rootProject.projectDir)
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
val compiler = IncrementalJvmCompilerRunner(classpath.toList(),
|
||||
val compiler = IncrementalJvmCompilerRunner(
|
||||
taskBuildDirectory,
|
||||
classpath.toList(),
|
||||
kaptAnnotationsFileUpdater,
|
||||
artifactDifferenceRegistryProvider,
|
||||
sourceAnnotationsRegistry,
|
||||
getJavaSourceRoots(),
|
||||
destinationDir,
|
||||
dirtySourcesSinceLastTimeFile,
|
||||
lastBuildInfoFile,
|
||||
kapt2GeneratedSourcesDir,
|
||||
artifactFile,
|
||||
cacheDirectory,
|
||||
cacheVersions,
|
||||
reporter)
|
||||
compiler.compile(allKotlinSources, changedFiles, args, messageCollector)
|
||||
|
||||
Reference in New Issue
Block a user