[Gradle, JS] Configure build and run in one place: configureMain
This commit is contained in:
+6
-8
@@ -41,8 +41,6 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
override val testTaskDescription: String
|
||||
get() = "Run all ${target.name} tests inside browser using karma and webpack"
|
||||
|
||||
private val webpackTaskName = disambiguateCamelCased("webpack")
|
||||
|
||||
override fun configureDefaultTestFramework(it: KotlinJsTest) {
|
||||
it.useKarma {
|
||||
useChromeHeadless()
|
||||
@@ -50,11 +48,11 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
}
|
||||
|
||||
override fun runTask(body: KotlinWebpack.() -> Unit) {
|
||||
(project.tasks.getByName(runTaskName) as KotlinWebpack).body()
|
||||
TODO()
|
||||
}
|
||||
|
||||
override fun webpackTask(body: KotlinWebpack.() -> Unit) {
|
||||
(project.tasks.getByName(webpackTaskName) as KotlinWebpack).body()
|
||||
TODO()
|
||||
}
|
||||
|
||||
@ExperimentalDce
|
||||
@@ -69,9 +67,9 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
configureBuild(compilation, dceTaskProvider)
|
||||
}
|
||||
|
||||
override fun configureRun(
|
||||
private fun configureRun(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDceTask>?
|
||||
dceTaskProvider: TaskProvider<KotlinJsDceTask>
|
||||
) {
|
||||
|
||||
val project = compilation.target.project
|
||||
@@ -126,9 +124,9 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun configureBuild(
|
||||
private fun configureBuild(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDceTask>?
|
||||
dceTaskProvider: TaskProvider<KotlinJsDceTask>
|
||||
) {
|
||||
val project = compilation.target.project
|
||||
val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||
|
||||
-15
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.gradle.targets.js.subtargets
|
||||
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.AbstractKotlinTargetConfigurator
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||
@@ -21,7 +20,6 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJsDce
|
||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.configureConventions
|
||||
import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry
|
||||
@@ -34,9 +32,6 @@ abstract class KotlinJsSubTarget(
|
||||
val project get() = target.project
|
||||
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||
|
||||
val runTaskName = disambiguateCamelCased("run")
|
||||
val testTaskName = disambiguateCamelCased("test")
|
||||
|
||||
abstract val testTaskDescription: String
|
||||
|
||||
final override lateinit var testRuns: NamedDomainObjectContainer<KotlinJsPlatformTestRun>
|
||||
@@ -136,14 +131,4 @@ abstract class KotlinJsSubTarget(
|
||||
}
|
||||
|
||||
protected abstract fun configureMain(compilation: KotlinJsCompilation)
|
||||
|
||||
protected abstract fun configureRun(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDce>?
|
||||
)
|
||||
|
||||
protected abstract fun configureBuild(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDce>?
|
||||
)
|
||||
}
|
||||
+5
-13
@@ -5,13 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.targets.js.subtargets
|
||||
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsNodeDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJsDce
|
||||
import javax.inject.Inject
|
||||
|
||||
open class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) :
|
||||
@@ -20,6 +18,8 @@ open class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) :
|
||||
override val testTaskDescription: String
|
||||
get() = "Run all ${target.name} tests inside nodejs using the builtin test framework"
|
||||
|
||||
private val runTaskName = disambiguateCamelCased("run")
|
||||
|
||||
override fun runTask(body: NodeJsExec.() -> Unit) {
|
||||
(project.tasks.getByName(runTaskName) as NodeJsExec).body()
|
||||
}
|
||||
@@ -29,24 +29,16 @@ open class KotlinNodeJs @Inject constructor(target: KotlinJsTarget) :
|
||||
}
|
||||
|
||||
override fun configureMain(compilation: KotlinJsCompilation) {
|
||||
configureRun(compilation, null)
|
||||
configureBuild(compilation, null)
|
||||
configureRun(compilation)
|
||||
}
|
||||
|
||||
override fun configureRun(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDce>?
|
||||
private fun configureRun(
|
||||
compilation: KotlinJsCompilation
|
||||
) {
|
||||
val runTaskHolder = NodeJsExec.create(compilation, disambiguateCamelCased("run"))
|
||||
target.runTask.dependsOn(runTaskHolder)
|
||||
}
|
||||
|
||||
override fun configureBuild(
|
||||
compilation: KotlinJsCompilation,
|
||||
dceTaskProvider: TaskProvider<KotlinJsDce>?
|
||||
) {
|
||||
}
|
||||
|
||||
override fun configureBuildVariants() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user