Add kotlinOptions to KotlinCompileCommon
This commit is contained in:
+2
@@ -41,6 +41,8 @@ interface KotlinJsCompile : KotlinCompile<KotlinJsOptions>
|
|||||||
|
|
||||||
interface KotlinJvmCompile : KotlinCompile<KotlinJvmOptions>
|
interface KotlinJvmCompile : KotlinCompile<KotlinJvmOptions>
|
||||||
|
|
||||||
|
interface KotlinCommonCompile : KotlinCompile<KotlinMultiplatformCommonOptions>
|
||||||
|
|
||||||
interface KotlinJsDce : Task {
|
interface KotlinJsDce : Task {
|
||||||
val dceOptions: KotlinJsDceOptions
|
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.GradleCompilerEnvironment
|
||||||
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
|
||||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
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 org.jetbrains.kotlin.incremental.ChangedFiles
|
||||||
import java.io.File
|
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 =
|
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
||||||
K2MetadataCompilerArguments()
|
K2MetadataCompilerArguments()
|
||||||
|
|
||||||
@@ -35,7 +44,12 @@ internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompil
|
|||||||
override fun findKotlinCompilerClasspath(project: Project): List<File> =
|
override fun findKotlinCompilerClasspath(project: Project): List<File> =
|
||||||
findKotlinMetadataCompilerClasspath(project)
|
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 classpathList = classpath.files.toMutableList()
|
||||||
val friendTask = friendTaskName?.let { project.tasks.findByName(it) } as? AbstractCompile
|
val friendTask = friendTaskName?.let { project.tasks.findByName(it) } as? AbstractCompile
|
||||||
friendTask?.let { classpathList.add(it.destinationDir) }
|
friendTask?.let { classpathList.add(it.destinationDir) }
|
||||||
@@ -43,9 +57,12 @@ internal open class KotlinCompileCommon : AbstractKotlinCompile<K2MetadataCompil
|
|||||||
with(args) {
|
with(args) {
|
||||||
classpath = classpathList.joinToString(File.pathSeparator)
|
classpath = classpathList.joinToString(File.pathSeparator)
|
||||||
destination = destinationDir.canonicalPath
|
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 messageCollector = GradleMessageCollector(logger)
|
||||||
val outputItemCollector = OutputItemsCollectorImpl()
|
val outputItemCollector = OutputItemsCollectorImpl()
|
||||||
val compilerRunner = GradleCompilerRunner(project)
|
val compilerRunner = GradleCompilerRunner(project)
|
||||||
|
|||||||
Reference in New Issue
Block a user