[Gradle, JS] Prepare for review

This commit is contained in:
Ilya Goncharov
2020-01-31 12:41:30 +03:00
parent 85919ed0fc
commit 6793fb285e
7 changed files with 8 additions and 17 deletions
@@ -43,7 +43,7 @@ internal val jvmPresetEntry = KotlinPresetEntry(
internal val jsPresetEntry = KotlinPresetEntry(
"js",
// need for commonization KotlinJsTargetPreset and KotlinJsIrTargetPreser
// need for commonization KotlinJsTargetPreset and KotlinJsIrTargetPreset
typeName("org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset", "org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl"),
typeName("org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl")
)
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.gradle.targets.js
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.plugin.Kotlin2JsSourceSetProcessor
import org.jetbrains.kotlin.gradle.plugin.KotlinOnlyTargetConfigurator
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetProcessor
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTestsConfigurator
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry
import org.jetbrains.kotlin.gradle.testing.testTaskName
import java.util.concurrent.Callable
open class KotlinJsTargetConfigurator(kotlinPluginVersion: String, val irConfigurator: KotlinJsIrTargetConfigurator?) :
open class KotlinJsTargetConfigurator(kotlinPluginVersion: String) :
KotlinOnlyTargetConfigurator<KotlinJsCompilation, KotlinJsTarget>(true, true, kotlinPluginVersion),
KotlinTargetWithTestsConfigurator<KotlinJsReportAggregatingTestRun, KotlinJsTarget> {
@@ -49,15 +49,13 @@ open class KotlinJsTargetPreset(
}
override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator(
kotlinPluginVersion,
irPreset?.let { KotlinJsIrTargetConfigurator(kotlinPluginVersion) }
kotlinPluginVersion
)
override fun getName(): String = PRESET_NAME
override fun createCompilationFactory(forTarget: KotlinOnlyTarget<KotlinJsCompilation>): KotlinJsCompilationFactory {
forTarget as KotlinJsTarget
return KotlinJsCompilationFactory(project, forTarget, irPreset?.let { forTarget.irTarget })
return KotlinJsCompilationFactory(project, forTarget, irPreset?.let { (forTarget as KotlinJsTarget).irTarget })
}
companion object {
@@ -80,8 +78,7 @@ class KotlinJsSingleTargetPreset(
irPreset?.let { LEGACY_DISAMBIGUATION_CLASSIFIER }
override fun createKotlinTargetConfigurator() = KotlinJsTargetConfigurator(
kotlinPluginVersion,
irPreset?.let { KotlinJsIrTargetConfigurator(kotlinPluginVersion) }
kotlinPluginVersion
)
}
@@ -23,8 +23,6 @@ import org.jetbrains.kotlin.gradle.tasks.registerTask
import org.slf4j.LoggerFactory
import javax.inject.Inject
private val log = LoggerFactory.getLogger("org.jetbrains.kotlin.gradle.targets.js.ir")
open class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
KotlinJsIrSubTarget(target, "browser"),
KotlinJsBrowserDsl {
@@ -59,7 +57,7 @@ open class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
@ExperimentalDceDsl
override fun dceTask(body: KotlinJsDce.() -> Unit) {
log.warn("dceTask configuration is useless with IR compiler. Use @JsExport on declarations instead.")
project.logger.warn("dceTask configuration is useless with IR compiler. Use @JsExport on declarations instead.")
}
override fun configureMain(compilation: KotlinJsIrCompilation) {
@@ -42,9 +42,5 @@ class KotlinJsIrCompilation(
override fun addSourcesToCompileTask(sourceSet: KotlinSourceSet, addAsCommonSources: Lazy<Boolean>) {
super.addSourcesToCompileTask(sourceSet, addAsCommonSources)
allSources.add(sourceSet.kotlin)
listOf(productionLinkTask, developmentLinkTask).forEach {
it.sourceFilesExtensions(sourceSet.customSourceFilesExtensions)
}
}
}
@@ -21,6 +21,7 @@ open class KotlinJsIrLink : Kotlin2JsCompile() {
@Input
lateinit var type: KotlinJsIrType
// Not check sources, only klib module
@Internal
override fun getSource(): FileTree = super.getSource()
@@ -63,7 +63,6 @@ class KotlinMocha(override val compilation: KotlinJsCompilation) :
exclude = task.excludePatterns
)
val mocha = npmProject.require("mocha/bin/mocha")
val file = task.nodeModulesToLoad