org.jetbrains.kotlin.buildtools.internal.JvmCompilationConfigurationImpl.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.buildtools.internal
import org.jetbrains.kotlin.buildtools.api.KotlinLogger
import org.jetbrains.kotlin.buildtools.api.SourcesChanges
import org.jetbrains.kotlin.buildtools.api.jvm.*
import java.io.File
internal data class AggregatedIcConfiguration(
val options: IncrementalJvmCompilationConfiguration
,
val parameters: P,
val sourcesChanges: SourcesChanges,
val workingDir: File,
)
internal class JvmCompilationConfigurationImpl(
override var kotlinScriptFilenameExtensions: Set = emptySet(),
override var logger: KotlinLogger = DefaultKotlinLogger,
) : JvmCompilationConfiguration {
internal var aggregatedIcConfiguration: AggregatedIcConfiguration<*>? = null
private set
override fun useLogger(logger: KotlinLogger): JvmCompilationConfiguration {
this.logger = logger
return this
}
override fun useKotlinScriptFilenameExtensions(kotlinScriptExtensions: Collection): JvmCompilationConfiguration {
this.kotlinScriptFilenameExtensions = kotlinScriptExtensions.toSet()
return this
}
override fun makeClasspathSnapshotBasedIncrementalCompilationConfiguration() = ClasspathSnapshotBasedIncrementalJvmCompilationConfigurationImpl()
override fun useIncrementalCompilation(
workingDirectory: File,
sourcesChanges: SourcesChanges,
approachParameters: P,
options: IncrementalJvmCompilationConfiguration
,
) {
aggregatedIcConfiguration = AggregatedIcConfiguration(options, approachParameters, sourcesChanges, workingDirectory)
}
}
internal abstract class JvmIncrementalCompilationConfigurationImpl
(
override var preciseJavaTrackingEnabled: Boolean = true,
override var preciseCompilationResultsBackupEnabled: Boolean = false,
override var incrementalCompilationCachesKeptInMemory: Boolean = false,
override var rootProjectDir: File? = null,
override var buildDir: File? = null,
override var forcedNonIncrementalMode: Boolean = false,
override var outputDirs: Set? = null,
) : IncrementalJvmCompilationConfiguration {
override fun setRootProjectDir(rootProjectDir: File): IncrementalJvmCompilationConfiguration
{
this.rootProjectDir = rootProjectDir
return this
}
override fun setBuildDir(buildDir: File): IncrementalJvmCompilationConfiguration
{
this.buildDir = buildDir
return this
}
override fun usePreciseJavaTracking(value: Boolean): IncrementalJvmCompilationConfiguration
{
preciseJavaTrackingEnabled = value
return this
}
override fun usePreciseCompilationResultsBackup(value: Boolean): IncrementalJvmCompilationConfiguration
{
preciseCompilationResultsBackupEnabled = value
return this
}
override fun keepIncrementalCompilationCachesInMemory(value: Boolean): IncrementalJvmCompilationConfiguration
{
incrementalCompilationCachesKeptInMemory = value
return this
}
override fun forceNonIncrementalMode(value: Boolean): IncrementalJvmCompilationConfiguration
{
forcedNonIncrementalMode = value
return this
}
override fun useOutputDirs(outputDirs: Collection): IncrementalJvmCompilationConfiguration {
this.outputDirs = outputDirs.toSet()
return this
}
}
internal class ClasspathSnapshotBasedIncrementalJvmCompilationConfigurationImpl(
override var assuredNoClasspathSnapshotsChanges: Boolean = false,
) :
JvmIncrementalCompilationConfigurationImpl(),
ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
override fun setRootProjectDir(rootProjectDir: File): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.setRootProjectDir(rootProjectDir)
return this
}
override fun setBuildDir(buildDir: File): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.setBuildDir(buildDir)
return this
}
override fun usePreciseJavaTracking(value: Boolean): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.usePreciseJavaTracking(value)
return this
}
override fun usePreciseCompilationResultsBackup(value: Boolean): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.usePreciseCompilationResultsBackup(value)
return this
}
override fun keepIncrementalCompilationCachesInMemory(value: Boolean): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.keepIncrementalCompilationCachesInMemory(value)
return this
}
override fun forceNonIncrementalMode(value: Boolean): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.forceNonIncrementalMode(value)
return this
}
override fun assureNoClasspathSnapshotsChanges(value: Boolean): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
assuredNoClasspathSnapshotsChanges = value
return this
}
override fun useOutputDirs(outputDirs: Collection): ClasspathSnapshotBasedIncrementalJvmCompilationConfiguration {
super.useOutputDirs(outputDirs)
return this
}
}