fixup! [Gradle, JS] Fix review remarks
- setup compiler args in appropriate fun - remove redundant
This commit is contained in:
+3
-1
@@ -9,6 +9,7 @@ import org.gradle.api.file.FileTree
|
|||||||
import org.gradle.api.file.RegularFileProperty
|
import org.gradle.api.file.RegularFileProperty
|
||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
||||||
|
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsOptions
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.DEVELOPMENT
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.DEVELOPMENT
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.PRODUCTION
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.PRODUCTION
|
||||||
@@ -45,7 +46,8 @@ open class KotlinJsIrLink : Kotlin2JsCompile() {
|
|||||||
outputFile
|
outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun configure() {
|
override fun setupCompilerArgs(args: K2JSCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
||||||
|
super.setupCompilerArgs(args, defaultsOnly, ignoreClasspathResolutionErrors)
|
||||||
when (type) {
|
when (type) {
|
||||||
PRODUCTION -> {
|
PRODUCTION -> {
|
||||||
kotlinOptions.configureOptions(ENABLE_DCE, GENERATE_D_TS)
|
kotlinOptions.configureOptions(ENABLE_DCE, GENERATE_D_TS)
|
||||||
|
|||||||
-24
@@ -54,34 +54,10 @@ abstract class KotlinJsIrSubTarget(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun produceKotlinLibrary() {
|
|
||||||
produceByFlags()
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun produceExecutable() {
|
internal fun produceExecutable() {
|
||||||
produceByFlags()
|
|
||||||
|
|
||||||
configureMain()
|
configureMain()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun produceByFlags(vararg flags: String) {
|
|
||||||
target.compilations
|
|
||||||
.matching { it.name == KotlinCompilation.TEST_COMPILATION_NAME }
|
|
||||||
.all {
|
|
||||||
it.kotlinOptions {
|
|
||||||
freeCompilerArgs += PRODUCE_JS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
target.compilations
|
|
||||||
.matching { it.name == KotlinCompilation.MAIN_COMPILATION_NAME }
|
|
||||||
.all {
|
|
||||||
it.kotlinOptions {
|
|
||||||
freeCompilerArgs += flags.toList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun testTask(body: KotlinJsTest.() -> Unit) {
|
override fun testTask(body: KotlinJsTest.() -> Unit) {
|
||||||
testRuns.getByName(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME).executionTask.configure(body)
|
testRuns.getByName(KotlinTargetWithTests.DEFAULT_TEST_RUN_NAME).executionTask.configure(body)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -86,9 +86,7 @@ constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun produceKotlinLibrary() {
|
override fun produceKotlinLibrary() {
|
||||||
produce(KotlinJsProducingType.KOTLIN_LIBRARY) {
|
produce(KotlinJsProducingType.KOTLIN_LIBRARY)
|
||||||
produceKotlinLibrary()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun produceExecutable() {
|
override fun produceExecutable() {
|
||||||
@@ -99,7 +97,7 @@ constructor(
|
|||||||
|
|
||||||
private fun produce(
|
private fun produce(
|
||||||
producingType: KotlinJsProducingType,
|
producingType: KotlinJsProducingType,
|
||||||
producer: KotlinJsIrSubTarget.() -> Unit
|
producer: KotlinJsIrSubTarget.() -> Unit = {}
|
||||||
) {
|
) {
|
||||||
check(this.producingType == null || this.producingType == producingType) {
|
check(this.producingType == null || this.producingType == producingType) {
|
||||||
"Only one producing type supported. Try to set $producingType but previously ${this.producingType} found"
|
"Only one producing type supported. Try to set $producingType but previously ${this.producingType} found"
|
||||||
|
|||||||
-8
@@ -72,14 +72,6 @@ open class KotlinJsIrTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
PRODUCE_UNZIPPED_KLIB
|
PRODUCE_UNZIPPED_KLIB
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
it.productionLinkTask.configure {
|
|
||||||
it.configure()
|
|
||||||
}
|
|
||||||
|
|
||||||
it.developmentLinkTask.configure {
|
|
||||||
it.configure()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-5
@@ -47,11 +47,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
private val irBrowser: KotlinBrowserJsIr?
|
private val irBrowser: KotlinBrowserJsIr?
|
||||||
get() = target.irTarget?.browser
|
get() = target.irTarget?.browser
|
||||||
|
|
||||||
override fun produceKotlinLibrary() {
|
|
||||||
super.produceKotlinLibrary()
|
|
||||||
irBrowser?.produceKotlinLibrary()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun produceExecutable() {
|
override fun produceExecutable() {
|
||||||
super.produceExecutable()
|
super.produceExecutable()
|
||||||
irBrowser?.produceExecutable()
|
irBrowser?.produceExecutable()
|
||||||
|
|||||||
-5
@@ -24,11 +24,6 @@ open class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
private val irNodejs: KotlinNodeJsIr?
|
private val irNodejs: KotlinNodeJsIr?
|
||||||
get() = target.irTarget?.nodejs
|
get() = target.irTarget?.nodejs
|
||||||
|
|
||||||
override fun produceKotlinLibrary() {
|
|
||||||
super.produceKotlinLibrary()
|
|
||||||
irNodejs?.produceKotlinLibrary()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun produceExecutable() {
|
override fun produceExecutable() {
|
||||||
super.produceExecutable()
|
super.produceExecutable()
|
||||||
irNodejs?.produceExecutable()
|
irNodejs?.produceExecutable()
|
||||||
|
|||||||
Reference in New Issue
Block a user