[JS, Wizard] Set js compiler per module
^KT-41418 fixed
This commit is contained in:
+25
-4
@@ -19,12 +19,23 @@ interface TargetIR : MultiplatformIR
|
|||||||
|
|
||||||
data class TargetAccessIR(
|
data class TargetAccessIR(
|
||||||
val type: ModuleSubType,
|
val type: ModuleSubType,
|
||||||
val nonDefaultName: String? // `null` stands for default target name
|
val nonDefaultName: String?, // `null` stands for default target name
|
||||||
|
val additionalParams: List<Any> = listOf()
|
||||||
) : TargetIR {
|
) : TargetIR {
|
||||||
override fun GradlePrinter.renderGradle() {
|
override fun GradlePrinter.renderGradle() {
|
||||||
+type.toString()
|
+type.toString()
|
||||||
par {
|
par {
|
||||||
nonDefaultName?.let { +it.quotified }
|
nonDefaultName?.let {
|
||||||
|
+it.quotified
|
||||||
|
if (additionalParams.isNotEmpty()) +", "
|
||||||
|
}
|
||||||
|
if (additionalParams.isNotEmpty()) {
|
||||||
|
additionalParams
|
||||||
|
.joinToString {
|
||||||
|
it.toString()
|
||||||
|
}
|
||||||
|
.apply { +this }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,8 +67,18 @@ data class DefaultTargetConfigurationIR(
|
|||||||
|
|
||||||
override fun GradlePrinter.renderGradle() {
|
override fun GradlePrinter.renderGradle() {
|
||||||
+targetAccess.type.toString()
|
+targetAccess.type.toString()
|
||||||
if (irs.isEmpty() || targetAccess.nonDefaultName != null) par {
|
if (irs.isEmpty() || targetAccess.nonDefaultName != null || targetAccess.additionalParams.isNotEmpty()) par {
|
||||||
targetAccess.nonDefaultName?.let { +it.quotified }
|
targetAccess.nonDefaultName?.let {
|
||||||
|
+it.quotified
|
||||||
|
if (targetAccess.additionalParams.isNotEmpty()) +", "
|
||||||
|
}
|
||||||
|
if (targetAccess.additionalParams.isNotEmpty()) {
|
||||||
|
targetAccess.additionalParams
|
||||||
|
.joinToString {
|
||||||
|
it.toString()
|
||||||
|
}
|
||||||
|
.apply { +this }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (irs.isNotEmpty()) {
|
if (irs.isNotEmpty()) {
|
||||||
+" "; inBrackets { irs.listNl() }
|
+" "; inBrackets { irs.listNl() }
|
||||||
|
|||||||
+7
-5
@@ -44,7 +44,6 @@ interface JSConfigurator : ModuleConfiguratorWithModuleType, ModuleConfiguratorW
|
|||||||
GradlePlugin.gradleProperties
|
GradlePlugin.gradleProperties
|
||||||
.addValues(
|
.addValues(
|
||||||
"kotlin.js.generate.executable.default" to "false",
|
"kotlin.js.generate.executable.default" to "false",
|
||||||
"kotlin.js.compiler" to settingsValue(module, compiler).text.toLowerCase()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
||||||
@@ -139,9 +138,6 @@ abstract class JsSinglePlatformModuleConfigurator :
|
|||||||
super<ModuleConfiguratorWithTests>.getConfiguratorSettings() +
|
super<ModuleConfiguratorWithTests>.getConfiguratorSettings() +
|
||||||
super<JSConfigurator>.getConfiguratorSettings()
|
super<JSConfigurator>.getConfiguratorSettings()
|
||||||
|
|
||||||
@NonNls
|
|
||||||
override val suggestedModuleName = "js"
|
|
||||||
|
|
||||||
override fun defaultTestFramework(): KotlinTestFramework = KotlinTestFramework.JS
|
override fun defaultTestFramework(): KotlinTestFramework = KotlinTestFramework.JS
|
||||||
|
|
||||||
override val canContainSubModules = false
|
override val canContainSubModules = false
|
||||||
@@ -158,7 +154,7 @@ abstract class JsSinglePlatformModuleConfigurator :
|
|||||||
module: Module
|
module: Module
|
||||||
): List<BuildSystemIR> = irsList {
|
): List<BuildSystemIR> = irsList {
|
||||||
"kotlin" {
|
"kotlin" {
|
||||||
"js" {
|
"js(${reader.settingsValue(module, JSConfigurator.compiler).text})" {
|
||||||
subTarget(module, reader)
|
subTarget(module, reader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,6 +167,9 @@ object BrowserJsSinglePlatformModuleConfigurator : JsSinglePlatformModuleConfigu
|
|||||||
@NonNls
|
@NonNls
|
||||||
override val id = "jsBrowserSinglePlatform"
|
override val id = "jsBrowserSinglePlatform"
|
||||||
|
|
||||||
|
@NonNls
|
||||||
|
override val suggestedModuleName = "browser"
|
||||||
|
|
||||||
override val moduleKind = ModuleKind.singleplatformJsBrowser
|
override val moduleKind = ModuleKind.singleplatformJsBrowser
|
||||||
|
|
||||||
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> {
|
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> {
|
||||||
@@ -189,6 +188,9 @@ object NodeJsSinglePlatformModuleConfigurator : JsSinglePlatformModuleConfigurat
|
|||||||
@NonNls
|
@NonNls
|
||||||
override val id = "jsNodeSinglePlatform"
|
override val id = "jsNodeSinglePlatform"
|
||||||
|
|
||||||
|
@NonNls
|
||||||
|
override val suggestedModuleName = "nodejs"
|
||||||
|
|
||||||
override val moduleKind = ModuleKind.singleplatformJsNode
|
override val moduleKind = ModuleKind.singleplatformJsNode
|
||||||
|
|
||||||
override fun GradleIRListBuilder.subTarget(module: Module, reader: Reader) {
|
override fun GradleIRListBuilder.subTarget(module: Module, reader: Reader) {
|
||||||
|
|||||||
+14
-11
@@ -65,10 +65,14 @@ interface SimpleTargetConfigurator : TargetConfigurator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Module.createTargetAccessIr(moduleSubType: ModuleSubType) =
|
internal fun Module.createTargetAccessIr(
|
||||||
|
moduleSubType: ModuleSubType,
|
||||||
|
additionalParams: List<Any?> = listOf()
|
||||||
|
) =
|
||||||
TargetAccessIR(
|
TargetAccessIR(
|
||||||
moduleSubType,
|
moduleSubType,
|
||||||
name.takeIf { it != moduleSubType.name }
|
name.takeIf { it != moduleSubType.name },
|
||||||
|
additionalParams.filterNotNull()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -94,9 +98,6 @@ object JsBrowserTargetConfigurator : JsTargetConfigurator, ModuleConfiguratorWit
|
|||||||
@NonNls
|
@NonNls
|
||||||
override val id = "jsBrowser"
|
override val id = "jsBrowser"
|
||||||
|
|
||||||
@NonNls
|
|
||||||
override val suggestedModuleName = "browser"
|
|
||||||
|
|
||||||
override val text = KotlinNewProjectWizardBundle.message("module.configurator.js.browser")
|
override val text = KotlinNewProjectWizardBundle.message("module.configurator.js.browser")
|
||||||
|
|
||||||
override fun defaultTestFramework(): KotlinTestFramework = KotlinTestFramework.JS
|
override fun defaultTestFramework(): KotlinTestFramework = KotlinTestFramework.JS
|
||||||
@@ -105,7 +106,10 @@ object JsBrowserTargetConfigurator : JsTargetConfigurator, ModuleConfiguratorWit
|
|||||||
module: Module
|
module: Module
|
||||||
): List<BuildSystemIR> = irsList {
|
): List<BuildSystemIR> = irsList {
|
||||||
+DefaultTargetConfigurationIR(
|
+DefaultTargetConfigurationIR(
|
||||||
module.createTargetAccessIr(ModuleSubType.js)
|
module.createTargetAccessIr(
|
||||||
|
ModuleSubType.js,
|
||||||
|
listOf(settingValue(module, JSConfigurator.compiler)?.text)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
browserSubTarget(module, this@createTargetIrs)
|
browserSubTarget(module, this@createTargetIrs)
|
||||||
}
|
}
|
||||||
@@ -116,17 +120,16 @@ object JsNodeTargetConfigurator : JsTargetConfigurator {
|
|||||||
@NonNls
|
@NonNls
|
||||||
override val id = "jsNode"
|
override val id = "jsNode"
|
||||||
|
|
||||||
@NonNls
|
|
||||||
override val suggestedModuleName = "nodeJs"
|
|
||||||
|
|
||||||
override val text = KotlinNewProjectWizardBundle.message("module.configurator.js.node")
|
override val text = KotlinNewProjectWizardBundle.message("module.configurator.js.node")
|
||||||
|
|
||||||
|
|
||||||
override fun Reader.createTargetIrs(
|
override fun Reader.createTargetIrs(
|
||||||
module: Module
|
module: Module
|
||||||
): List<BuildSystemIR> = irsList {
|
): List<BuildSystemIR> = irsList {
|
||||||
+DefaultTargetConfigurationIR(
|
+DefaultTargetConfigurationIR(
|
||||||
module.createTargetAccessIr(ModuleSubType.js)
|
module.createTargetAccessIr(
|
||||||
|
ModuleSubType.js,
|
||||||
|
listOf(settingValue(module, JSConfigurator.compiler)?.text)
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
nodejsSubTarget(module, this@createTargetIrs)
|
nodejsSubTarget(module, this@createTargetIrs)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -287,7 +287,7 @@ object FrontendApplicationProjectTemplate : ProjectTemplate() {
|
|||||||
get() = listOf(
|
get() = listOf(
|
||||||
KotlinPlugin.modules.reference withValue listOf(
|
KotlinPlugin.modules.reference withValue listOf(
|
||||||
Module(
|
Module(
|
||||||
"js",
|
"browser",
|
||||||
BrowserJsSinglePlatformModuleConfigurator,
|
BrowserJsSinglePlatformModuleConfigurator,
|
||||||
template = SimpleJsClientTemplate(),
|
template = SimpleJsClientTemplate(),
|
||||||
sourcesets = SourcesetType.ALL.map { type ->
|
sourcesets = SourcesetType.ALL.map { type ->
|
||||||
@@ -312,7 +312,7 @@ object ReactApplicationProjectTemplate : ProjectTemplate() {
|
|||||||
get() = listOf(
|
get() = listOf(
|
||||||
KotlinPlugin.modules.reference withValue listOf(
|
KotlinPlugin.modules.reference withValue listOf(
|
||||||
Module(
|
Module(
|
||||||
"js",
|
"react",
|
||||||
BrowserJsSinglePlatformModuleConfigurator,
|
BrowserJsSinglePlatformModuleConfigurator,
|
||||||
template = ReactJsClientTemplate(),
|
template = ReactJsClientTemplate(),
|
||||||
sourcesets = SourcesetType.ALL.map { type ->
|
sourcesets = SourcesetType.ALL.map { type ->
|
||||||
@@ -431,7 +431,7 @@ object NodeJsApplicationProjectTemplate : ProjectTemplate() {
|
|||||||
get() = listOf(
|
get() = listOf(
|
||||||
KotlinPlugin.modules.reference withValue listOf(
|
KotlinPlugin.modules.reference withValue listOf(
|
||||||
Module(
|
Module(
|
||||||
"js",
|
"nodejs",
|
||||||
NodeJsSinglePlatformModuleConfigurator,
|
NodeJsSinglePlatformModuleConfigurator,
|
||||||
template = SimpleNodeJsTemplate(),
|
template = SimpleNodeJsTemplate(),
|
||||||
sourcesets = SourcesetType.ALL.map { type ->
|
sourcesets = SourcesetType.ALL.map { type ->
|
||||||
|
|||||||
Reference in New Issue
Block a user