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