[Gradle] Pass multiplatform structure to K2
^KT-56210 Verification Pending
This commit is contained in:
committed by
Space Team
parent
6c618ae5cc
commit
4f48cac601
-4
@@ -78,7 +78,6 @@ internal open class GradleCompilerRunner(
|
|||||||
*/
|
*/
|
||||||
fun runJvmCompilerAsync(
|
fun runJvmCompilerAsync(
|
||||||
sourcesToCompile: List<File>,
|
sourcesToCompile: List<File>,
|
||||||
commonSources: List<File>,
|
|
||||||
javaPackagePrefix: String?,
|
javaPackagePrefix: String?,
|
||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment,
|
environment: GradleCompilerEnvironment,
|
||||||
@@ -86,7 +85,6 @@ internal open class GradleCompilerRunner(
|
|||||||
taskOutputsBackup: TaskOutputsBackup?
|
taskOutputsBackup: TaskOutputsBackup?
|
||||||
): WorkQueue? {
|
): WorkQueue? {
|
||||||
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
||||||
args.commonSources = commonSources.map { it.absolutePath }.toTypedArray()
|
|
||||||
args.javaPackagePrefix = javaPackagePrefix
|
args.javaPackagePrefix = javaPackagePrefix
|
||||||
if (args.jdkHome == null && !args.noJdk) args.jdkHome = jdkHome.absolutePath
|
if (args.jdkHome == null && !args.noJdk) args.jdkHome = jdkHome.absolutePath
|
||||||
loggerProvider.kotlinInfo("Kotlin compilation 'jdkHome' argument: ${args.jdkHome}")
|
loggerProvider.kotlinInfo("Kotlin compilation 'jdkHome' argument: ${args.jdkHome}")
|
||||||
@@ -99,13 +97,11 @@ internal open class GradleCompilerRunner(
|
|||||||
*/
|
*/
|
||||||
fun runJsCompilerAsync(
|
fun runJsCompilerAsync(
|
||||||
kotlinSources: List<File>,
|
kotlinSources: List<File>,
|
||||||
kotlinCommonSources: List<File>,
|
|
||||||
args: K2JSCompilerArguments,
|
args: K2JSCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment,
|
environment: GradleCompilerEnvironment,
|
||||||
taskOutputsBackup: TaskOutputsBackup?
|
taskOutputsBackup: TaskOutputsBackup?
|
||||||
): WorkQueue? {
|
): WorkQueue? {
|
||||||
args.freeArgs += kotlinSources.map { it.absolutePath }
|
args.freeArgs += kotlinSources.map { it.absolutePath }
|
||||||
args.commonSources = kotlinCommonSources.map { it.absolutePath }.toTypedArray()
|
|
||||||
return runCompilerAsync(KotlinCompilerClass.JS, args, environment, taskOutputsBackup)
|
return runCompilerAsync(KotlinCompilerClass.JS, args, environment, taskOutputsBackup)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* 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.gradle.dsl
|
||||||
|
|
||||||
|
import org.gradle.api.provider.Provider
|
||||||
|
|
||||||
|
internal val KotlinCommonCompilerOptions.usesK2: Provider<Boolean>
|
||||||
|
get() = this.languageVersion
|
||||||
|
.orElse(KotlinVersion.DEFAULT)
|
||||||
|
.map { version -> version >= KotlinVersion.KOTLIN_2_0 }
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.gradle.plugin.mpp.compilationImpl
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.K2Compile
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure
|
||||||
|
|
||||||
|
internal object KotlinCompilationK2MultiplatformConfigurator : KotlinCompilationImplFactory.PreConfigure {
|
||||||
|
override fun configure(compilation: KotlinCompilationImpl) {
|
||||||
|
compilation.project.tasks.matching { it.name == compilation.compileKotlinTaskName }.configureEach { compileTask ->
|
||||||
|
if (compileTask !is K2Compile) return@configureEach
|
||||||
|
|
||||||
|
compileTask.multiplatformStructure.dependsOnEdges.set(compilation.project.provider {
|
||||||
|
compilation.allKotlinSourceSets.flatMap { sourceSet ->
|
||||||
|
sourceSet.dependsOn.map { dependsOn ->
|
||||||
|
K2MultiplatformStructure.DependsOnEdge(sourceSet.name, dependsOn.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
compileTask.multiplatformStructure.fragments.set(compilation.project.provider {
|
||||||
|
compilation.allKotlinSourceSets.map { sourceSet ->
|
||||||
|
K2MultiplatformStructure.Fragment(sourceSet.name, sourceSet.kotlin.asFileTree)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -42,7 +42,7 @@ internal class KotlinCompilationImplFactory(
|
|||||||
DefaultProcessResourcesTaskNameFactory,
|
DefaultProcessResourcesTaskNameFactory,
|
||||||
|
|
||||||
private val preConfigureAction: PreConfigure =
|
private val preConfigureAction: PreConfigure =
|
||||||
EmptyPreConfigure,
|
KotlinCompilationK2MultiplatformConfigurator,
|
||||||
|
|
||||||
private val postConfigureAction: PostConfigure =
|
private val postConfigureAction: PostConfigure =
|
||||||
DefaultKotlinCompilationPostConfigure
|
DefaultKotlinCompilationPostConfigure
|
||||||
|
|||||||
+20
-3
@@ -10,8 +10,11 @@ import org.gradle.api.file.FileTree
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerToolOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerToolOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinNativeCompilerOptions
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.usesK2
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode
|
import org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.fragmentSourcesCompilerArgs
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.fragmentsCompilerArgs
|
||||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.project.model.LanguageSettings
|
import org.jetbrains.kotlin.project.model.LanguageSettings
|
||||||
@@ -46,7 +49,8 @@ internal fun buildKotlinNativeKlibCompilerArgs(
|
|||||||
libraryVersion: String,
|
libraryVersion: String,
|
||||||
sharedCompilationData: SharedCompilationData?,
|
sharedCompilationData: SharedCompilationData?,
|
||||||
source: FileTree,
|
source: FileTree,
|
||||||
commonSourcesTree: FileTree
|
commonSourcesTree: FileTree,
|
||||||
|
k2MultiplatformCompilationData: K2MultiplatformStructure
|
||||||
): List<String> = mutableListOf<String>().apply {
|
): List<String> = mutableListOf<String>().apply {
|
||||||
addAll(buildKotlinNativeMainArgs(outFile, optimized, debuggable, target, CompilerOutputKind.LIBRARY, libraries))
|
addAll(buildKotlinNativeMainArgs(outFile, optimized, debuggable, target, CompilerOutputKind.LIBRARY, libraries))
|
||||||
|
|
||||||
@@ -76,10 +80,23 @@ internal fun buildKotlinNativeKlibCompilerArgs(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compilerOptions.usesK2.get()) {
|
||||||
|
/*
|
||||||
|
For now, we only pass multiplatform structure to K2 for platform compilations
|
||||||
|
Metadata compilations will compile against pre-compiled klibs from their dependsOn
|
||||||
|
*/
|
||||||
|
if (sharedCompilationData == null) {
|
||||||
|
add("-Xfragments=${k2MultiplatformCompilationData.fragmentsCompilerArgs.joinToString(",")}")
|
||||||
|
add("-Xfragment-sources=${k2MultiplatformCompilationData.fragmentSourcesCompilerArgs.joinToString(",")}")
|
||||||
|
add("-Xdepends-on=${k2MultiplatformCompilationData.dependsOnCompilerArgs.joinToString(",")}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addAll(buildKotlinNativeCompileCommonArgs(languageSettings, compilerOptions, compilerPlugins))
|
addAll(buildKotlinNativeCompileCommonArgs(languageSettings, compilerOptions, compilerPlugins))
|
||||||
|
|
||||||
addAll(source.map { it.absolutePath })
|
addAll(source.map { it.absolutePath })
|
||||||
if (!commonSourcesTree.isEmpty) {
|
|
||||||
|
if (!compilerOptions.usesK2.get() && !commonSourcesTree.isEmpty) {
|
||||||
add("-Xcommon-sources=${commonSourcesTree.joinToString(separator = ",") { it.absolutePath }}")
|
add("-Xcommon-sources=${commonSourcesTree.joinToString(separator = ",") { it.absolutePath }}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-22
@@ -37,7 +37,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmMetadataCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmMetadataCompilationData
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmNativeCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmNativeCompilationData
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
|
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
|
||||||
import org.jetbrains.kotlin.gradle.plugin.tcsOrNull
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.KonanPropertiesBuildService
|
import org.jetbrains.kotlin.gradle.targets.native.KonanPropertiesBuildService
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.internal.isAllowCommonizer
|
import org.jetbrains.kotlin.gradle.targets.native.internal.isAllowCommonizer
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
|
import org.jetbrains.kotlin.gradle.targets.native.tasks.*
|
||||||
@@ -314,6 +313,7 @@ internal constructor(
|
|||||||
private val execOperations: ExecOperations
|
private val execOperations: ExecOperations
|
||||||
) : AbstractKotlinNativeCompile<KotlinCommonOptions, StubK2NativeCompilerArguments>(objectFactory),
|
) : AbstractKotlinNativeCompile<KotlinCommonOptions, StubK2NativeCompilerArguments>(objectFactory),
|
||||||
KotlinCompile<KotlinCommonOptions>,
|
KotlinCompile<KotlinCommonOptions>,
|
||||||
|
K2Compile,
|
||||||
KotlinCompilationTask<KotlinNativeCompilerOptions> {
|
KotlinCompilationTask<KotlinNativeCompilerOptions> {
|
||||||
|
|
||||||
@get:Input
|
@get:Input
|
||||||
@@ -354,6 +354,9 @@ internal constructor(
|
|||||||
@get:Internal // these sources are normally a subset of `source` ones which are already tracked
|
@get:Internal // these sources are normally a subset of `source` ones which are already tracked
|
||||||
val commonSources: ConfigurableFileCollection = project.files()
|
val commonSources: ConfigurableFileCollection = project.files()
|
||||||
|
|
||||||
|
@get:Nested
|
||||||
|
override val multiplatformStructure: K2MultiplatformStructure = objectFactory.newInstance()
|
||||||
|
|
||||||
private val commonSourcesTree: FileTree
|
private val commonSourcesTree: FileTree
|
||||||
get() = commonSources.asFileTree
|
get() = commonSources.asFileTree
|
||||||
|
|
||||||
@@ -454,33 +457,33 @@ internal constructor(
|
|||||||
return SharedCompilationData(manifestFile, isAllowCommonizer, refinesModule)
|
return SharedCompilationData(manifestFile, isAllowCommonizer, refinesModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun buildKotlinNativeKlibCompilerArgs(): List<String> = buildKotlinNativeKlibCompilerArgs(
|
||||||
|
outFile = outputFile.get(),
|
||||||
|
optimized = optimized,
|
||||||
|
debuggable = debuggable,
|
||||||
|
target = konanTarget,
|
||||||
|
libraries = libraries.files.filterKlibsPassedToCompiler(),
|
||||||
|
languageSettings = languageSettings,
|
||||||
|
compilerOptions = compilerOptions,
|
||||||
|
compilerPlugins = listOfNotNull(
|
||||||
|
compilerPluginClasspath?.let { CompilerPluginData(it, compilerPluginOptions) },
|
||||||
|
kotlinPluginData?.orNull?.let { CompilerPluginData(it.classpath, it.options) }
|
||||||
|
),
|
||||||
|
shortModuleName = shortModuleName,
|
||||||
|
friendModule = friendModule,
|
||||||
|
libraryVersion = artifactVersion,
|
||||||
|
sharedCompilationData = createSharedCompilationDataOrNull(),
|
||||||
|
source = sources.asFileTree,
|
||||||
|
commonSourcesTree = commonSourcesTree,
|
||||||
|
k2MultiplatformCompilationData = multiplatformStructure
|
||||||
|
)
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun compile() {
|
fun compile() {
|
||||||
val output = outputFile.get()
|
val output = outputFile.get()
|
||||||
output.parentFile.mkdirs()
|
output.parentFile.mkdirs()
|
||||||
|
|
||||||
val plugins = listOfNotNull(
|
val buildArgs = buildKotlinNativeKlibCompilerArgs()
|
||||||
compilerPluginClasspath?.let { CompilerPluginData(it, compilerPluginOptions) },
|
|
||||||
kotlinPluginData?.orNull?.let { CompilerPluginData(it.classpath, it.options) }
|
|
||||||
)
|
|
||||||
|
|
||||||
val buildArgs = buildKotlinNativeKlibCompilerArgs(
|
|
||||||
output,
|
|
||||||
optimized,
|
|
||||||
debuggable,
|
|
||||||
konanTarget,
|
|
||||||
libraries.files.filterKlibsPassedToCompiler(),
|
|
||||||
languageSettings,
|
|
||||||
compilerOptions,
|
|
||||||
plugins,
|
|
||||||
shortModuleName,
|
|
||||||
friendModule,
|
|
||||||
artifactVersion,
|
|
||||||
createSharedCompilationDataOrNull(),
|
|
||||||
sources.asFileTree,
|
|
||||||
commonSourcesTree
|
|
||||||
)
|
|
||||||
|
|
||||||
KotlinNativeCompilerRunner(
|
KotlinNativeCompilerRunner(
|
||||||
settings = runnerSettings,
|
settings = runnerSettings,
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.gradle.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.Task
|
||||||
|
import org.gradle.api.tasks.Internal
|
||||||
|
import org.gradle.api.tasks.Nested
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analogous to [KotlinCompile] for K2
|
||||||
|
* This does not extend [KotlinCompile], since [KotlinCompile] carries an unwanted/conflicting
|
||||||
|
* type parameter `<out T : KotlinCommonOptions>`
|
||||||
|
*/
|
||||||
|
internal interface K2Compile : Task {
|
||||||
|
@get:Internal
|
||||||
|
val kotlinOptions: KotlinCommonOptions
|
||||||
|
|
||||||
|
@get:Nested
|
||||||
|
val multiplatformStructure: K2MultiplatformStructure
|
||||||
|
}
|
||||||
+79
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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.gradle.tasks
|
||||||
|
|
||||||
|
import org.gradle.api.file.FileCollection
|
||||||
|
import org.gradle.api.provider.ListProperty
|
||||||
|
import org.gradle.api.provider.SetProperty
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
import org.gradle.work.Incremental
|
||||||
|
import org.gradle.work.NormalizeLineEndings
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.usesK2
|
||||||
|
|
||||||
|
@InternalKotlinGradlePluginApi
|
||||||
|
abstract class K2MultiplatformStructure {
|
||||||
|
|
||||||
|
@InternalKotlinGradlePluginApi
|
||||||
|
data class DependsOnEdge(
|
||||||
|
@Input
|
||||||
|
val fromFragmentName: String,
|
||||||
|
@Input
|
||||||
|
val toFragmentName: String
|
||||||
|
)
|
||||||
|
|
||||||
|
@InternalKotlinGradlePluginApi
|
||||||
|
data class Fragment(
|
||||||
|
@Input
|
||||||
|
val fragmentName: String,
|
||||||
|
|
||||||
|
@get:InputFiles
|
||||||
|
@get:IgnoreEmptyDirectories
|
||||||
|
@get:Incremental
|
||||||
|
@get:NormalizeLineEndings
|
||||||
|
@get:PathSensitive(PathSensitivity.RELATIVE)
|
||||||
|
val sources: FileCollection
|
||||||
|
)
|
||||||
|
|
||||||
|
@get:Nested
|
||||||
|
abstract val dependsOnEdges: SetProperty<DependsOnEdge>
|
||||||
|
|
||||||
|
@get:Nested
|
||||||
|
abstract val fragments: ListProperty<Fragment>
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val K2MultiplatformStructure.fragmentsCompilerArgs: Array<String>
|
||||||
|
get() = fragments.get().map { it.fragmentName }.toSet().toTypedArray()
|
||||||
|
|
||||||
|
internal val K2MultiplatformStructure.fragmentSourcesCompilerArgs: Array<String>
|
||||||
|
get() = fragments.get().flatMap { sourceSet ->
|
||||||
|
sourceSet.sources.files.map { sourceFile -> "${sourceSet.fragmentName};${sourceFile.absolutePath}" }
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
|
internal val K2MultiplatformStructure.dependsOnCompilerArgs: Array<String>
|
||||||
|
get() = dependsOnEdges.get().map { edge ->
|
||||||
|
"${edge.fromFragmentName}:${edge.toFragmentName}"
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
|
internal fun CommonCompilerArguments.configureK2Multiplatform(multiplatformStructure: K2MultiplatformStructure) {
|
||||||
|
fragments = multiplatformStructure.fragmentsCompilerArgs
|
||||||
|
fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs
|
||||||
|
dependsOnDependencies = multiplatformStructure.dependsOnCompilerArgs
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun CommonCompilerArguments.configureMultiplatform(
|
||||||
|
options: KotlinCommonCompilerOptions,
|
||||||
|
k1CommonSources: FileCollection,
|
||||||
|
k2MultiplatformFragments: K2MultiplatformStructure
|
||||||
|
) {
|
||||||
|
if (options.usesK2.get()) {
|
||||||
|
configureK2Multiplatform(k2MultiplatformFragments)
|
||||||
|
} else {
|
||||||
|
commonSources = k1CommonSources.map { it.absolutePath }.toTypedArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
-4
@@ -526,6 +526,7 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
workerExecutor: WorkerExecutor,
|
workerExecutor: WorkerExecutor,
|
||||||
objectFactory: ObjectFactory
|
objectFactory: ObjectFactory
|
||||||
) : AbstractKotlinCompile<K2JVMCompilerArguments>(objectFactory, workerExecutor),
|
) : AbstractKotlinCompile<K2JVMCompilerArguments>(objectFactory, workerExecutor),
|
||||||
|
K2Compile,
|
||||||
@Suppress("TYPEALIAS_EXPANSION_DEPRECATION") KotlinJvmCompileDsl,
|
@Suppress("TYPEALIAS_EXPANSION_DEPRECATION") KotlinJvmCompileDsl,
|
||||||
KotlinCompilationTask<KotlinJvmCompilerOptions>,
|
KotlinCompilationTask<KotlinJvmCompilerOptions>,
|
||||||
UsesKotlinJavaToolchain {
|
UsesKotlinJavaToolchain {
|
||||||
@@ -546,6 +547,9 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
.property(kotlinOptions)
|
.property(kotlinOptions)
|
||||||
.chainedDisallowChanges()
|
.chainedDisallowChanges()
|
||||||
|
|
||||||
|
@get:Nested
|
||||||
|
override val multiplatformStructure: K2MultiplatformStructure = objectFactory.newInstance()
|
||||||
|
|
||||||
/** A package prefix that is used for locating Java sources in a directory structure with non-full-depth packages.
|
/** A package prefix that is used for locating Java sources in a directory structure with non-full-depth packages.
|
||||||
*
|
*
|
||||||
* Example: a Java source file with `package com.example.my.package` is located in directory `src/main/java/my/package`.
|
* Example: a Java source file with `package com.example.my.package` is located in directory `src/main/java/my/package`.
|
||||||
@@ -689,6 +693,12 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
args.configureMultiplatform(
|
||||||
|
compilerOptions,
|
||||||
|
k1CommonSources = commonSourceSet.asFileTree,
|
||||||
|
k2MultiplatformFragments = multiplatformStructure
|
||||||
|
)
|
||||||
|
|
||||||
if (reportingSettings().buildReportMode == BuildReportMode.VERBOSE) {
|
if (reportingSettings().buildReportMode == BuildReportMode.VERBOSE) {
|
||||||
args.reportPerf = true
|
args.reportPerf = true
|
||||||
}
|
}
|
||||||
@@ -714,7 +724,7 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
|
|
||||||
val scriptSources = scriptSources.asFileTree.files
|
val scriptSources = scriptSources.asFileTree.files
|
||||||
val javaSources = javaSources.files
|
val javaSources = javaSources.files
|
||||||
val gradlePrintingMessageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors,)
|
val gradlePrintingMessageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors)
|
||||||
val gradleMessageCollector = GradleErrorMessageCollector(gradlePrintingMessageCollector, kotlinPluginVersion = getKotlinPluginVersion(logger))
|
val gradleMessageCollector = GradleErrorMessageCollector(gradlePrintingMessageCollector, kotlinPluginVersion = getKotlinPluginVersion(logger))
|
||||||
val outputItemCollector = OutputItemsCollectorImpl()
|
val outputItemCollector = OutputItemsCollectorImpl()
|
||||||
val compilerRunner = compilerRunner.get()
|
val compilerRunner = compilerRunner.get()
|
||||||
@@ -751,7 +761,6 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
logger.info("Script file extensions: ${scriptExtensions.get().joinToString()}")
|
logger.info("Script file extensions: ${scriptExtensions.get().joinToString()}")
|
||||||
compilerRunner.runJvmCompilerAsync(
|
compilerRunner.runJvmCompilerAsync(
|
||||||
(kotlinSources + scriptSources + javaSources).toList(),
|
(kotlinSources + scriptSources + javaSources).toList(),
|
||||||
commonSourceSet.toList(),
|
|
||||||
javaPackagePrefix,
|
javaPackagePrefix,
|
||||||
args,
|
args,
|
||||||
environment,
|
environment,
|
||||||
@@ -913,7 +922,8 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
) : AbstractKotlinCompile<K2JSCompilerArguments>(objectFactory, workerExecutor),
|
) : AbstractKotlinCompile<K2JSCompilerArguments>(objectFactory, workerExecutor),
|
||||||
KotlinCompilationTask<KotlinJsCompilerOptions>,
|
KotlinCompilationTask<KotlinJsCompilerOptions>,
|
||||||
UsesLibraryFilterCachingService,
|
UsesLibraryFilterCachingService,
|
||||||
KotlinJsCompile {
|
KotlinJsCompile,
|
||||||
|
K2Compile {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
incremental = true
|
incremental = true
|
||||||
@@ -977,6 +987,9 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
internal var executionTimeFreeCompilerArgs: List<String>? = null
|
internal var executionTimeFreeCompilerArgs: List<String>? = null
|
||||||
|
|
||||||
|
@get:Nested
|
||||||
|
override val multiplatformStructure: K2MultiplatformStructure = objectFactory.newInstance()
|
||||||
|
|
||||||
override fun createCompilerArgs(): K2JSCompilerArguments =
|
override fun createCompilerArgs(): K2JSCompilerArguments =
|
||||||
K2JSCompilerArguments()
|
K2JSCompilerArguments()
|
||||||
|
|
||||||
@@ -1003,6 +1016,13 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
} else {
|
} else {
|
||||||
args.outputFile = outputFileProperty.get().absoluteFile.normalize().absolutePath
|
args.outputFile = outputFileProperty.get().absoluteFile.normalize().absolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args.configureMultiplatform(
|
||||||
|
compilerOptions,
|
||||||
|
k1CommonSources = commonSourceSet.asFileTree,
|
||||||
|
k2MultiplatformFragments = multiplatformStructure
|
||||||
|
)
|
||||||
|
|
||||||
// Overriding freeArgs from compilerOptions with enhanced one + additional one set on execution phase
|
// Overriding freeArgs from compilerOptions with enhanced one + additional one set on execution phase
|
||||||
// containing additional arguments based on the js compilation configuration
|
// containing additional arguments based on the js compilation configuration
|
||||||
val localExecutionTimeFreeCompilerArgs = executionTimeFreeCompilerArgs
|
val localExecutionTimeFreeCompilerArgs = executionTimeFreeCompilerArgs
|
||||||
@@ -1155,7 +1175,6 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
processArgs(args)
|
processArgs(args)
|
||||||
compilerRunner.runJsCompilerAsync(
|
compilerRunner.runJsCompilerAsync(
|
||||||
kotlinSources.toList(),
|
kotlinSources.toList(),
|
||||||
commonSourceSet.toList(),
|
|
||||||
args,
|
args,
|
||||||
environment,
|
environment,
|
||||||
taskOutputsBackup
|
taskOutputsBackup
|
||||||
|
|||||||
Reference in New Issue
Block a user