[Gradle, JS] Adopt changes about compilerOptions
This commit is contained in:
+1
-10
@@ -17,16 +17,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GradleDeprecatedOption(
|
@GradleDeprecatedOption(
|
||||||
"Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName",
|
message = "Only for legacy backend. For IR backend please use task.destinationDirectory and moduleName",
|
||||||
"1.10",
|
|
||||||
DeprecationLevel.WARNING
|
|
||||||
)
|
|
||||||
@GradleOption(
|
|
||||||
value = DefaultValues.StringNullDefault::class,
|
|
||||||
gradleInputType = GradleInputTypes.INTERNAL // handled by task 'outputFileProperty'
|
|
||||||
)
|
|
||||||
@GradleDeprecatedOption(
|
|
||||||
message = "Use task 'outputFileProperty' to specify location",
|
|
||||||
level = DeprecationLevel.WARNING,
|
level = DeprecationLevel.WARNING,
|
||||||
removeAfter = "1.9.0"
|
removeAfter = "1.9.0"
|
||||||
)
|
)
|
||||||
|
|||||||
+4
-1
@@ -50,7 +50,10 @@ interface CompilerJsOptions : org.jetbrains.kotlin.gradle.dsl.CompilerCommonOpti
|
|||||||
*/
|
*/
|
||||||
@Deprecated(message = "Use task 'outputFileProperty' to specify location", level = DeprecationLevel.WARNING)
|
@Deprecated(message = "Use task 'outputFileProperty' to specify location", level = DeprecationLevel.WARNING)
|
||||||
@get:org.gradle.api.tasks.Internal
|
@get:org.gradle.api.tasks.Internal
|
||||||
val outputFile: org.gradle.api.provider.Property<kotlin.String>
|
val outputFile: org.gradle.api.provider.Property<kotlin.String?>
|
||||||
|
|
||||||
|
@get:org.gradle.api.tasks.Input
|
||||||
|
val outputName: org.gradle.api.provider.Property<kotlin.String>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate source map
|
* Generate source map
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ internal abstract class CompilerJsOptionsDefault @javax.inject.Inject constructo
|
|||||||
objectFactory.property(kotlin.Boolean::class.java).convention(true)
|
objectFactory.property(kotlin.Boolean::class.java).convention(true)
|
||||||
|
|
||||||
@Deprecated(message = "Use task 'outputFileProperty' to specify location", level = DeprecationLevel.WARNING)
|
@Deprecated(message = "Use task 'outputFileProperty' to specify location", level = DeprecationLevel.WARNING)
|
||||||
override val outputFile: org.gradle.api.provider.Property<kotlin.String> =
|
override val outputFile: org.gradle.api.provider.Property<kotlin.String?> =
|
||||||
objectFactory.property(kotlin.String::class.java)
|
objectFactory.property(kotlin.String::class.java)
|
||||||
|
|
||||||
override val sourceMap: org.gradle.api.provider.Property<kotlin.Boolean> =
|
override val sourceMap: org.gradle.api.provider.Property<kotlin.Boolean> =
|
||||||
|
|||||||
+8
-7
@@ -52,6 +52,7 @@ internal const val COMPILER_CLASSPATH_CONFIGURATION_NAME = "kotlinCompilerClassp
|
|||||||
internal const val KLIB_COMMONIZER_CLASSPATH_CONFIGURATION_NAME = "kotlinKlibCommonizerClasspath"
|
internal const val KLIB_COMMONIZER_CLASSPATH_CONFIGURATION_NAME = "kotlinKlibCommonizerClasspath"
|
||||||
|
|
||||||
val KOTLIN_DSL_NAME = "kotlin"
|
val KOTLIN_DSL_NAME = "kotlin"
|
||||||
|
|
||||||
@Deprecated("Should be removed with 'platform.js' plugin removal")
|
@Deprecated("Should be removed with 'platform.js' plugin removal")
|
||||||
val KOTLIN_JS_DSL_NAME = "kotlin2js"
|
val KOTLIN_JS_DSL_NAME = "kotlin2js"
|
||||||
val KOTLIN_OPTIONS_DSL_NAME = "kotlinOptions"
|
val KOTLIN_OPTIONS_DSL_NAME = "kotlinOptions"
|
||||||
@@ -156,11 +157,7 @@ internal abstract class KotlinSourceSetProcessor<T : AbstractKotlinCompile<*>>(
|
|||||||
protected fun applyStandardTaskConfiguration(taskConfiguration: AbstractKotlinCompileConfig<*>) {
|
protected fun applyStandardTaskConfiguration(taskConfiguration: AbstractKotlinCompileConfig<*>) {
|
||||||
taskConfiguration.configureTask {
|
taskConfiguration.configureTask {
|
||||||
it.description = taskDescription
|
it.description = taskDescription
|
||||||
if (it is Kotlin2JsCompile) {
|
it.destinationDirectory.convention(defaultKotlinDestinationDir)
|
||||||
it.defaultDestinationDirectory.convention(defaultKotlinDestinationDir)
|
|
||||||
} else {
|
|
||||||
it.destinationDirectory.convention(defaultKotlinDestinationDir)
|
|
||||||
}
|
|
||||||
it.libraries.from({ kotlinCompilation.compileDependencyFiles })
|
it.libraries.from({ kotlinCompilation.compileDependencyFiles })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -294,8 +291,11 @@ internal class KotlinJsIrSourceSetProcessor(
|
|||||||
compilation.binaries
|
compilation.binaries
|
||||||
.withType(JsIrBinary::class.java)
|
.withType(JsIrBinary::class.java)
|
||||||
.all { binary ->
|
.all { binary ->
|
||||||
val configAction = KotlinJsIrLinkConfig(compilation)
|
val configAction = KotlinJsIrLinkConfig(binary)
|
||||||
applyStandardTaskConfiguration(configAction)
|
configAction.configureTask {
|
||||||
|
it.description = taskDescription
|
||||||
|
it.libraries.from({ kotlinCompilation.compileDependencyFiles })
|
||||||
|
}
|
||||||
configAction.configureTask { task ->
|
configAction.configureTask { task ->
|
||||||
task.modeProperty.set(binary.mode)
|
task.modeProperty.set(binary.mode)
|
||||||
task.dependsOn(kotlinTask)
|
task.dependsOn(kotlinTask)
|
||||||
@@ -887,6 +887,7 @@ internal fun Project.forEachVariant(action: (BaseVariant) -> Unit) {
|
|||||||
androidExtension.featureVariants.all(action)
|
androidExtension.featureVariants.all(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is TestExtension -> androidExtension.applicationVariants.all(action)
|
is TestExtension -> androidExtension.applicationVariants.all(action)
|
||||||
}
|
}
|
||||||
if (androidExtension is TestedExtension) {
|
if (androidExtension is TestedExtension) {
|
||||||
|
|||||||
+3
-3
@@ -205,9 +205,9 @@ abstract class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
),
|
),
|
||||||
listOf(compilation)
|
listOf(compilation)
|
||||||
) { task ->
|
) { task ->
|
||||||
val entryFileProvider = binary.linkSyncTask.map {
|
val entryFileProvider = binary.linkSyncTask.zip(binary.linkTask) { sync, link ->
|
||||||
it.destinationDir
|
sync.destinationDir
|
||||||
.resolve(binary.linkTask.get().outputName.get() + ".js")
|
.resolve(link.compilerOptions.outputName.get() + ".js")
|
||||||
}
|
}
|
||||||
|
|
||||||
task.description = "build webpack ${mode.name.toLowerCase()} bundle"
|
task.description = "build webpack ${mode.name.toLowerCase()} bundle"
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ constructor(
|
|||||||
val linkTask = binary.linkTask
|
val linkTask = binary.linkTask
|
||||||
|
|
||||||
val compiledWasmFile = linkTask.map { link ->
|
val compiledWasmFile = linkTask.map { link ->
|
||||||
link.destinationDirectory.asFile.get().resolve(link.outputName.get() + ".wasm")
|
link.destinationDirectory.asFile.get().resolve(link.compilerOptions.outputName.get() + ".wasm")
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO This is temporary solution that overrides compiled files that triggers recompile and reoptimize wasm every time (when binaryen is enabled)
|
//TODO This is temporary solution that overrides compiled files that triggers recompile and reoptimize wasm every time (when binaryen is enabled)
|
||||||
|
|||||||
+2
-57
@@ -15,8 +15,8 @@ import org.gradle.workers.WorkerExecutor
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||||
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.CompilerJsOptionsDefault
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsImpl
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
||||||
@@ -37,8 +37,7 @@ import javax.inject.Inject
|
|||||||
@CacheableTask
|
@CacheableTask
|
||||||
abstract class KotlinJsIrLink @Inject constructor(
|
abstract class KotlinJsIrLink @Inject constructor(
|
||||||
objectFactory: ObjectFactory,
|
objectFactory: ObjectFactory,
|
||||||
workerExecutor: WorkerExecutor,
|
workerExecutor: WorkerExecutor
|
||||||
private val projectLayout: ProjectLayout
|
|
||||||
) : Kotlin2JsCompile(
|
) : Kotlin2JsCompile(
|
||||||
objectFactory.newInstance(CompilerJsOptionsDefault::class.java),
|
objectFactory.newInstance(CompilerJsOptionsDefault::class.java),
|
||||||
objectFactory,
|
objectFactory,
|
||||||
@@ -61,11 +60,6 @@ abstract class KotlinJsIrLink @Inject constructor(
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
internal lateinit var compilation: KotlinCompilationData<*>
|
internal lateinit var compilation: KotlinCompilationData<*>
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
val platformType by project.provider {
|
|
||||||
compilation.platformType
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal val propertiesProvider = PropertiesProvider(project)
|
internal val propertiesProvider = PropertiesProvider(project)
|
||||||
@@ -152,53 +146,4 @@ abstract class KotlinJsIrLink @Inject constructor(
|
|||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
.filterNot { it.isEmpty() }
|
.filterNot { it.isEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupCompilerArgs(args: K2JSCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
|
||||||
when (mode) {
|
|
||||||
PRODUCTION -> {
|
|
||||||
kotlinOptions.configureOptions(ENABLE_DCE, GENERATE_D_TS, MINIMIZED_MEMBER_NAMES)
|
|
||||||
}
|
|
||||||
|
|
||||||
DEVELOPMENT -> {
|
|
||||||
kotlinOptions.configureOptions(GENERATE_D_TS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val alreadyDefinedOutputMode = kotlinOptions.freeCompilerArgs
|
|
||||||
.any { it.startsWith(PER_MODULE) }
|
|
||||||
if (!alreadyDefinedOutputMode) {
|
|
||||||
kotlinOptions.freeCompilerArgs += outputGranularity.toCompilerArgument()
|
|
||||||
}
|
|
||||||
super.setupCompilerArgs(args, defaultsOnly, ignoreClasspathResolutionErrors)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KotlinJsOptions.configureOptions(vararg additionalCompilerArgs: String) {
|
|
||||||
freeCompilerArgs += (additionalCompilerArgs.toList() + PRODUCE_JS + "$ENTRY_IR_MODULE=${entryModule.get().asFile.canonicalPath}")
|
|
||||||
.mapNotNull { arg ->
|
|
||||||
if (kotlinOptions.freeCompilerArgs
|
|
||||||
.any { it.startsWith(arg) }
|
|
||||||
) null else arg
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platformType == KotlinPlatformType.wasm) {
|
|
||||||
freeCompilerArgs += WASM_BACKEND
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
override val filteredArgumentsMap: Map<String, String>
|
|
||||||
get() {
|
|
||||||
val superFiltered = super.filteredArgumentsMap
|
|
||||||
return superFiltered.mapValues { (key, value) ->
|
|
||||||
if (key != K2JSCompilerArguments::freeArgs.name) {
|
|
||||||
value
|
|
||||||
} else {
|
|
||||||
value
|
|
||||||
.removePrefix("[")
|
|
||||||
.removeSuffix("]")
|
|
||||||
.split(", ")
|
|
||||||
.filter { !it.contains(ENTRY_IR_MODULE) }
|
|
||||||
.joinToString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+8
-5
@@ -123,9 +123,8 @@ abstract class KotlinJsIrSubTarget(
|
|||||||
|
|
||||||
testJs.inputFileProperty.set(
|
testJs.inputFileProperty.set(
|
||||||
project.layout.file(
|
project.layout.file(
|
||||||
binary.linkSyncTask.map {
|
binary.linkSyncTask.flatMap { copyTask ->
|
||||||
val linkTask = binary.linkTask.get()
|
val extension = when (compilation.platformType) {
|
||||||
val extension = when (linkTask.platformType) {
|
|
||||||
KotlinPlatformType.wasm -> {
|
KotlinPlatformType.wasm -> {
|
||||||
".mjs"
|
".mjs"
|
||||||
}
|
}
|
||||||
@@ -136,8 +135,12 @@ abstract class KotlinJsIrSubTarget(
|
|||||||
|
|
||||||
else -> error("Only JS and WASM supported for KotlinJsTest")
|
else -> error("Only JS and WASM supported for KotlinJsTest")
|
||||||
}
|
}
|
||||||
it.destinationDir
|
binary.linkTask
|
||||||
.resolve(linkTask.outputName.get() + extension)
|
.flatMap { linkTask -> linkTask.compilerOptions.outputName }
|
||||||
|
.map { outputName ->
|
||||||
|
copyTask.destinationDir
|
||||||
|
.resolve(outputName + extension)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
-11
@@ -11,7 +11,6 @@ import org.gradle.api.Task
|
|||||||
import org.gradle.api.tasks.Copy
|
import org.gradle.api.tasks.Copy
|
||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsImpl
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator.Companion.runTaskNameSuffix
|
import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator.Companion.runTaskNameSuffix
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||||
@@ -114,7 +113,6 @@ constructor(
|
|||||||
|
|
||||||
private val commonLazy by lazy {
|
private val commonLazy by lazy {
|
||||||
compilations.all { compilation ->
|
compilations.all { compilation ->
|
||||||
val npmProject = compilation.npmProject
|
|
||||||
compilation.binaries
|
compilation.binaries
|
||||||
.withType(JsIrBinary::class.java)
|
.withType(JsIrBinary::class.java)
|
||||||
.all { binary ->
|
.all { binary ->
|
||||||
@@ -122,15 +120,6 @@ constructor(
|
|||||||
val tsValidationTask = registerTypeScriptCheckTask(binary)
|
val tsValidationTask = registerTypeScriptCheckTask(binary)
|
||||||
|
|
||||||
binary.linkTask.configure {
|
binary.linkTask.configure {
|
||||||
it.destinationDirectory.set(
|
|
||||||
project.buildDir
|
|
||||||
.resolve(COMPILE_SYNC)
|
|
||||||
.resolve(if (compilation.platformType == KotlinPlatformType.wasm) "wasm" else "js")
|
|
||||||
.resolve(compilation.name)
|
|
||||||
.resolve(binary.name)
|
|
||||||
.resolve(NpmProject.DIST_FOLDER)
|
|
||||||
)
|
|
||||||
(it.kotlinOptions as KotlinJsOptionsImpl).outputName = npmProject.name
|
|
||||||
|
|
||||||
it.finalizedBy(syncTask)
|
it.finalizedBy(syncTask)
|
||||||
|
|
||||||
|
|||||||
+8
-12
@@ -908,6 +908,7 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
!classpathSnapshotFiles.shrunkPreviousClasspathSnapshotFile.exists() -> {
|
!classpathSnapshotFiles.shrunkPreviousClasspathSnapshotFile.exists() -> {
|
||||||
NotAvailableDueToMissingClasspathSnapshot(classpathSnapshotFiles)
|
NotAvailableDueToMissingClasspathSnapshot(classpathSnapshotFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
inputChanges.getFileChanges(classpathSnapshotProperties.classpathSnapshot).none() -> NoChanges(classpathSnapshotFiles)
|
inputChanges.getFileChanges(classpathSnapshotProperties.classpathSnapshot).none() -> NoChanges(classpathSnapshotFiles)
|
||||||
else -> ToBeComputedByIncrementalCompiler(classpathSnapshotFiles)
|
else -> ToBeComputedByIncrementalCompiler(classpathSnapshotFiles)
|
||||||
}
|
}
|
||||||
@@ -976,17 +977,10 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Workaround to be able to use default value and change it later based on external input
|
|
||||||
@get:Internal
|
|
||||||
internal abstract val defaultDestinationDirectory: DirectoryProperty
|
|
||||||
|
|
||||||
@Deprecated("Use destinationDirectory and moduleName instead")
|
@Deprecated("Use destinationDirectory and moduleName instead")
|
||||||
@get:Internal
|
@get:Internal
|
||||||
abstract val outputFileProperty: Property<File>
|
abstract val outputFileProperty: Property<File>
|
||||||
|
|
||||||
@get:Input
|
|
||||||
abstract val outputName: Property<String>
|
|
||||||
|
|
||||||
// Workaround to add additional compiler args based on the exising one
|
// Workaround to add additional compiler args based on the exising one
|
||||||
// Currently there is a logic to add additional compiler arguments based on already existing one.
|
// Currently there is a logic to add additional compiler arguments based on already existing one.
|
||||||
// And it is not possible to update compilerOptions.freeCompilerArgs using some kind of .map
|
// And it is not possible to update compilerOptions.freeCompilerArgs using some kind of .map
|
||||||
@@ -1012,13 +1006,15 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
(compilerOptions as CompilerJsOptionsDefault).fillDefaultValues(args)
|
(compilerOptions as CompilerJsOptionsDefault).fillDefaultValues(args)
|
||||||
super.setupCompilerArgs(args, defaultsOnly = defaultsOnly, ignoreClasspathResolutionErrors = ignoreClasspathResolutionErrors)
|
super.setupCompilerArgs(args, defaultsOnly = defaultsOnly, ignoreClasspathResolutionErrors = ignoreClasspathResolutionErrors)
|
||||||
|
|
||||||
if (kotlinOptions.isIrBackendEnabled()) {
|
if (isIrBackendEnabled()) {
|
||||||
if (kotlinOptions.outputFile != null) {
|
val outputFilePath: String? = compilerOptions.outputFile.orNull
|
||||||
args.outputDir = (kotlinOptions as KotlinJsOptionsImpl).destDir
|
if (outputFilePath != null) {
|
||||||
kotlinOptions.outputFile?.let { args.outputName = File(it).nameWithoutExtension }
|
val outputFile = File(outputFilePath)
|
||||||
|
args.outputDir = (if (outputFile.extension == "") outputFile else outputFile.parentFile).normalize().absolutePath
|
||||||
|
args.outputName = outputFile.nameWithoutExtension
|
||||||
} else {
|
} else {
|
||||||
args.outputDir = destinationDirectory.get().asFile.normalize().absolutePath
|
args.outputDir = destinationDirectory.get().asFile.normalize().absolutePath
|
||||||
args.outputName = outputName.get()
|
args.outputName = compilerOptions.outputName.get()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args.outputFile = outputFileProperty.get().absoluteFile.normalize().absolutePath
|
args.outputFile = outputFileProperty.get().absoluteFile.normalize().absolutePath
|
||||||
|
|||||||
+7
-49
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.tasks.configuration
|
package org.jetbrains.kotlin.gradle.tasks.configuration
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptionsImpl
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.isMainCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.isMainCompilationData
|
||||||
@@ -35,60 +34,19 @@ internal open class BaseKotlin2JsCompileConfig<TASK : Kotlin2JsCompile>(
|
|||||||
|
|
||||||
configureAdditionalFreeCompilerArguments(task, compilation)
|
configureAdditionalFreeCompilerArguments(task, compilation)
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
task.compilerOptions.outputName.convention(
|
||||||
task.compilerOptions.outputFile.convention(
|
compilation.ownModuleName
|
||||||
task.defaultDestinationDirectory.zip(task.enhancedFreeCompilerArgs) { destDir, freeArgs ->
|
|
||||||
val baseName = if (compilation.isMainCompilationData()) {
|
|
||||||
project.name
|
|
||||||
} else {
|
|
||||||
"${project.name}_${compilation.compilationPurpose}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeArgs.contains(PRODUCE_UNZIPPED_KLIB)) {
|
|
||||||
destDir.asFile.absoluteFile.normalize().absolutePath
|
|
||||||
} else {
|
|
||||||
if (compilation is KotlinJsIrCompilation) {
|
|
||||||
destDir.asFile.resolve("$baseName.$KLIB_TYPE").absoluteFile.normalize().absolutePath
|
|
||||||
} else {
|
|
||||||
val extensionName = if (compilation.platformType == KotlinPlatformType.wasm) ".mjs" else ".js"
|
|
||||||
destDir.asFile.resolve("${compilation.ownModuleName}$extensionName").absolutePath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
task.outputFileProperty.value(
|
task.outputFileProperty.value(
|
||||||
task.compilerOptions.outputFile.map { File(it) }
|
task.destinationDirectory.flatMap { dir ->
|
||||||
)
|
task.compilerOptions.outputName.map { name ->
|
||||||
|
dir.file(name).asFile
|
||||||
task.destinationDirectory
|
|
||||||
.fileProvider(
|
|
||||||
task.outputFileProperty.zip(task.enhancedFreeCompilerArgs) { outputFile, freeArgs ->
|
|
||||||
if (freeArgs.contains(PRODUCE_UNZIPPED_KLIB)) {
|
|
||||||
outputFile
|
|
||||||
} else {
|
|
||||||
outputFile.parentFile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.disallowChanges()
|
|
||||||
|
|
||||||
task.outputName.value(task.project.provider {
|
|
||||||
(task.kotlinOptions as KotlinJsOptionsImpl).outputName ?: compilation.ownModuleName
|
|
||||||
}).disallowChanges()
|
|
||||||
|
|
||||||
task.optionalOutputFile.fileProvider(
|
|
||||||
task.outputFileProperty.flatMap { outputFile ->
|
|
||||||
task.enhancedFreeCompilerArgs.flatMap { freeArgs ->
|
|
||||||
task.project.providers.provider {
|
|
||||||
outputFile.takeUnless {
|
|
||||||
freeArgs.contains(PRODUCE_UNZIPPED_KLIB)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).disallowChanges()
|
)
|
||||||
|
|
||||||
task.libraryCache.set(libraryCacheService).also { task.libraryCache.disallowChanges() }
|
task.libraryCache.set(libraryCacheService).also { task.libraryCache.disallowChanges() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-5
@@ -5,18 +5,20 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.tasks.configuration
|
package org.jetbrains.kotlin.gradle.tasks.configuration
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
|
||||||
import java.io.File
|
|
||||||
import org.gradle.api.InvalidUserDataException
|
import org.gradle.api.InvalidUserDataException
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinCompilationData
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.*
|
import org.jetbrains.kotlin.gradle.targets.js.ir.*
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||||
|
|
||||||
internal open class KotlinJsIrLinkConfig(
|
internal open class KotlinJsIrLinkConfig(
|
||||||
compilation: KotlinJsIrCompilation
|
private val binary: JsIrBinary
|
||||||
) : BaseKotlin2JsCompileConfig<KotlinJsIrLink>(compilation) {
|
) : BaseKotlin2JsCompileConfig<KotlinJsIrLink>(binary.compilation) {
|
||||||
|
|
||||||
|
private val compilation
|
||||||
|
get() = binary.compilation
|
||||||
|
|
||||||
init {
|
init {
|
||||||
configureTask { task ->
|
configureTask { task ->
|
||||||
@@ -33,6 +35,15 @@ internal open class KotlinJsIrLinkConfig(
|
|||||||
}
|
}
|
||||||
).disallowChanges()
|
).disallowChanges()
|
||||||
task.compilation = compilation
|
task.compilation = compilation
|
||||||
|
task.destinationDirectory.convention(
|
||||||
|
project.layout.buildDirectory
|
||||||
|
.dir(COMPILE_SYNC)
|
||||||
|
.map { it.dir(if (compilation.platformType == KotlinPlatformType.wasm) "wasm" else "js") }
|
||||||
|
.map { it.dir(compilation.name) }
|
||||||
|
.map { it.dir(binary.name) }
|
||||||
|
.map { it.dir(NpmProject.DIST_FOLDER) }
|
||||||
|
)
|
||||||
|
task.compilerOptions.outputName.convention(project.provider { compilation.npmProject.name })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user