Update KotlinCompileCommon task to use compiler options
^KT-27301 In Progress
This commit is contained in:
+6
-1
@@ -335,7 +335,12 @@ internal class KotlinCommonSourceSetProcessor(
|
|||||||
override fun doRegisterTask(project: Project, taskName: String): TaskProvider<out KotlinCompileCommon> {
|
override fun doRegisterTask(project: Project, taskName: String): TaskProvider<out KotlinCompileCommon> {
|
||||||
val configAction = KotlinCompileCommonConfig(kotlinCompilation)
|
val configAction = KotlinCompileCommonConfig(kotlinCompilation)
|
||||||
applyStandardTaskConfiguration(configAction)
|
applyStandardTaskConfiguration(configAction)
|
||||||
return tasksProvider.registerKotlinCommonTask(project, taskName, kotlinCompilation.kotlinOptions, configAction)
|
return tasksProvider.registerKotlinCommonTask(
|
||||||
|
project,
|
||||||
|
taskName,
|
||||||
|
kotlinCompilation.compilerOptions.options as CompilerMultiplatformCommonOptions,
|
||||||
|
configAction
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -33,17 +33,29 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@CacheableTask
|
@CacheableTask
|
||||||
abstract class KotlinCompileCommon @Inject constructor(
|
abstract class KotlinCompileCommon @Inject constructor(
|
||||||
override val kotlinOptions: KotlinMultiplatformCommonOptions,
|
override val compilerOptions: CompilerMultiplatformCommonOptions,
|
||||||
workerExecutor: WorkerExecutor,
|
workerExecutor: WorkerExecutor,
|
||||||
objectFactory: ObjectFactory
|
objectFactory: ObjectFactory
|
||||||
) : AbstractKotlinCompile<K2MetadataCompilerArguments>(objectFactory, workerExecutor),
|
) : AbstractKotlinCompile<K2MetadataCompilerArguments>(objectFactory, workerExecutor),
|
||||||
|
KotlinCompilationTask<CompilerMultiplatformCommonOptions>,
|
||||||
KotlinCommonCompile {
|
KotlinCommonCompile {
|
||||||
|
|
||||||
|
init {
|
||||||
|
compilerOptions.verbose.convention(logger.isDebugEnabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
@Deprecated("Replaced by compilerOptions input", replaceWith = ReplaceWith("compilerOptions"))
|
||||||
|
override val kotlinOptions: KotlinMultiplatformCommonOptions = object : KotlinMultiplatformCommonOptions {
|
||||||
|
override val options: CompilerMultiplatformCommonOptions
|
||||||
|
get() = compilerOptions
|
||||||
|
}
|
||||||
|
|
||||||
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
||||||
K2MetadataCompilerArguments()
|
K2MetadataCompilerArguments()
|
||||||
|
|
||||||
override fun setupCompilerArgs(args: K2MetadataCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
override fun setupCompilerArgs(args: K2MetadataCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
||||||
args.apply { fillDefaultValues() }
|
(compilerOptions as CompilerMultiplatformCommonOptionsDefault).fillDefaultValues(args)
|
||||||
super.setupCompilerArgs(args, defaultsOnly = defaultsOnly, ignoreClasspathResolutionErrors = ignoreClasspathResolutionErrors)
|
super.setupCompilerArgs(args, defaultsOnly = defaultsOnly, ignoreClasspathResolutionErrors = ignoreClasspathResolutionErrors)
|
||||||
|
|
||||||
args.moduleName = this@KotlinCompileCommon.moduleName.get()
|
args.moduleName = this@KotlinCompileCommon.moduleName.get()
|
||||||
@@ -64,7 +76,7 @@ abstract class KotlinCompileCommon @Inject constructor(
|
|||||||
refinesPaths = refinesMetadataPaths.map { it.absolutePath }.toTypedArray()
|
refinesPaths = refinesMetadataPaths.map { it.absolutePath }.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
(kotlinOptions as KotlinMultiplatformCommonOptionsImpl).updateArguments(args)
|
(compilerOptions as CompilerMultiplatformCommonOptionsDefault).fillCompilerArguments(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:PathSensitive(PathSensitivity.RELATIVE)
|
@get:PathSensitive(PathSensitivity.RELATIVE)
|
||||||
|
|||||||
+6
-3
@@ -24,7 +24,7 @@ import org.gradle.api.tasks.TaskContainer
|
|||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.jetbrains.kotlin.gradle.dsl.CompilerJsOptions
|
import org.jetbrains.kotlin.gradle.dsl.CompilerJsOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.CompilerJvmOptions
|
import org.jetbrains.kotlin.gradle.dsl.CompilerJvmOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
import org.jetbrains.kotlin.gradle.dsl.CompilerMultiplatformCommonOptions
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
||||||
import org.jetbrains.kotlin.gradle.tasks.configuration.*
|
import org.jetbrains.kotlin.gradle.tasks.configuration.*
|
||||||
|
|
||||||
@@ -134,12 +134,15 @@ internal open class KotlinTasksProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun registerKotlinCommonTask(
|
fun registerKotlinCommonTask(
|
||||||
project: Project, taskName: String, kotlinOptions: KotlinCommonOptions, configuration: KotlinCompileCommonConfig
|
project: Project,
|
||||||
|
taskName: String,
|
||||||
|
compilerOptions: CompilerMultiplatformCommonOptions,
|
||||||
|
configuration: KotlinCompileCommonConfig
|
||||||
): TaskProvider<out KotlinCompileCommon> {
|
): TaskProvider<out KotlinCompileCommon> {
|
||||||
return project.registerTask(
|
return project.registerTask(
|
||||||
taskName,
|
taskName,
|
||||||
KotlinCompileCommon::class.java,
|
KotlinCompileCommon::class.java,
|
||||||
constructorArgs = listOf(kotlinOptions)
|
constructorArgs = listOf(compilerOptions)
|
||||||
).also {
|
).also {
|
||||||
configuration.execute(it)
|
configuration.execute(it)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user