[Gradle, JS] Add checks on module name set before browser and nodejs
- Add outputModuleName for compilations KT-32017
This commit is contained in:
+12
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationWithResources
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsSubTargetContainerDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.JsBinary
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsBinaryContainer
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson
|
||||
@@ -31,6 +32,17 @@ open class KotlinJsCompilation(
|
||||
WrapUtil.toDomainObjectSet(JsBinary::class.java)
|
||||
)
|
||||
|
||||
var outputModuleName: String? = null
|
||||
set(value) {
|
||||
(target as KotlinJsSubTargetContainerDsl).apply {
|
||||
check(!isBrowserConfigured && !isNodejsConfigured) {
|
||||
"Please set outputModuleName for compilation before initialize browser() or nodejs() on target"
|
||||
}
|
||||
}
|
||||
|
||||
field = value
|
||||
}
|
||||
|
||||
override val processResourcesTaskName: String
|
||||
get() = disambiguateName("processResources")
|
||||
|
||||
|
||||
+7
@@ -43,6 +43,13 @@ constructor(
|
||||
internal set
|
||||
|
||||
override var moduleName: String? = null
|
||||
set(value) {
|
||||
check(!isBrowserConfigured && !isNodejsConfigured) {
|
||||
"Please set moduleName before initialize browser() or nodejs()"
|
||||
}
|
||||
irTarget?.moduleName = value
|
||||
field = value
|
||||
}
|
||||
|
||||
val disambiguationClassifierInPlatform: String?
|
||||
get() = disambiguationClassifier?.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY)
|
||||
|
||||
+6
@@ -40,6 +40,12 @@ constructor(
|
||||
internal set
|
||||
|
||||
override var moduleName: String? = null
|
||||
set(value) {
|
||||
check(!isBrowserConfigured && !isNodejsConfigured) {
|
||||
"Please set moduleName before initialize browser() or nodejs()"
|
||||
}
|
||||
field = value
|
||||
}
|
||||
|
||||
val disambiguationClassifierInPlatform: String?
|
||||
get() = disambiguationClassifier?.removeJsCompilerSuffix(KotlinJsCompilerType.IR)
|
||||
|
||||
+4
@@ -92,6 +92,10 @@ open class NpmProject(val compilation: KotlinJsCompilation) {
|
||||
internal fun resolve(name: String): File? = modules.resolve(name)
|
||||
|
||||
private fun buildNpmProjectName(): String {
|
||||
compilation.outputModuleName?.let {
|
||||
return it
|
||||
}
|
||||
|
||||
val project = target.project
|
||||
|
||||
val moduleName = target.moduleName
|
||||
|
||||
Reference in New Issue
Block a user