Add kotlinOptions to KotlinCompileCommon
This commit is contained in:
+2
@@ -41,6 +41,8 @@ interface KotlinJsCompile : KotlinCompile<KotlinJsOptions>
|
||||
|
||||
interface KotlinJvmCompile : KotlinCompile<KotlinJvmOptions>
|
||||
|
||||
interface KotlinCommonCompile : KotlinCompile<KotlinMultiplatformCommonOptions>
|
||||
|
||||
interface KotlinJsDce : Task {
|
||||
val dceOptions: KotlinJsDceOptions
|
||||
|
||||
|
||||
+20
-3
@@ -22,10 +22,19 @@ import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
|
||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformCommonOptionsImpl
|
||||
import org.jetbrains.kotlin.gradle.dsl.fillDefaultValues
|
||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||
import java.io.File
|
||||
|
||||
internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompilerArguments>() {
|
||||
internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompilerArguments>(), KotlinCommonCompile {
|
||||
|
||||
private val kotlinOptionsImpl = KotlinMultiplatformCommonOptionsImpl()
|
||||
override val kotlinOptions: KotlinMultiplatformCommonOptions
|
||||
get() = kotlinOptionsImpl
|
||||
|
||||
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
||||
K2MetadataCompilerArguments()
|
||||
|
||||
@@ -35,7 +44,12 @@ internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompil
|
||||
override fun findKotlinCompilerClasspath(project: Project): List<File> =
|
||||
findKotlinMetadataCompilerClasspath(project)
|
||||
|
||||
override fun callCompiler(args: K2MetadataCompilerArguments, sourceRoots: SourceRoots, changedFiles: ChangedFiles) {
|
||||
override fun setupCompilerArgs(args: K2MetadataCompilerArguments, defaultsOnly: Boolean) {
|
||||
super.setupCompilerArgs(args, defaultsOnly)
|
||||
args.apply { fillDefaultValues() }
|
||||
|
||||
if (defaultsOnly) return
|
||||
|
||||
val classpathList = classpath.files.toMutableList()
|
||||
val friendTask = friendTaskName?.let { project.tasks.findByName(it) } as? AbstractCompile
|
||||
friendTask?.let { classpathList.add(it.destinationDir) }
|
||||
@@ -43,9 +57,12 @@ internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompil
|
||||
with(args) {
|
||||
classpath = classpathList.joinToString(File.pathSeparator)
|
||||
destination = destinationDir.canonicalPath
|
||||
freeArgs = sourceRoots.kotlinSourceFiles.mapTo(ArrayList<String>()) { it.canonicalPath }
|
||||
}
|
||||
|
||||
kotlinOptionsImpl.updateArguments(args)
|
||||
}
|
||||
|
||||
override fun callCompiler(args: K2MetadataCompilerArguments, sourceRoots: SourceRoots, changedFiles: ChangedFiles) {
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
val outputItemCollector = OutputItemsCollectorImpl()
|
||||
val compilerRunner = GradleCompilerRunner(project)
|
||||
|
||||
Reference in New Issue
Block a user