[Gradle, JS] Remove redundant classes
This commit is contained in:
-12
@@ -187,18 +187,6 @@ open class KotlinJsPluginWrapper @Inject constructor(
|
||||
override fun createTestRegistry(project: Project) = KotlinTestsRegistry(project, "test")
|
||||
}
|
||||
|
||||
open class KotlinJsIrPluginWrapper @Inject constructor(
|
||||
fileResolver: FileResolver
|
||||
) : KotlinBasePluginWrapper(fileResolver) {
|
||||
override fun getPlugin(project: Project, kotlinGradleBuildServices: KotlinGradleBuildServices): Plugin<Project> =
|
||||
KotlinJsIrPlugin(kotlinPluginVersion)
|
||||
|
||||
override val projectExtensionClass: KClass<out KotlinJsIrProjectExtension>
|
||||
get() = KotlinJsIrProjectExtension::class
|
||||
|
||||
override fun createTestRegistry(project: Project) = KotlinTestsRegistry(project, "test")
|
||||
}
|
||||
|
||||
open class KotlinMultiplatformPluginWrapper @Inject constructor(
|
||||
fileResolver: FileResolver,
|
||||
private val featurePreviews: FeaturePreviews
|
||||
|
||||
+2
-1
@@ -43,7 +43,8 @@ constructor(
|
||||
) :
|
||||
KotlinOnlyTarget<KotlinJsCompilation>(project, platformType),
|
||||
KotlinTargetWithTests<JsAggregatingExecutionSource, KotlinJsReportAggregatingTestRun>,
|
||||
KotlinJsTargetDsl, KotlinJsSubtargetContainerDsl {
|
||||
KotlinJsTargetDsl,
|
||||
KotlinJsSubtargetContainerDsl {
|
||||
override lateinit var testRuns: NamedDomainObjectContainer<KotlinJsReportAggregatingTestRun>
|
||||
internal set
|
||||
|
||||
|
||||
-24
@@ -30,30 +30,6 @@ interface KotlinJsSubtargetContainerDsl : KotlinTarget {
|
||||
fun whenBrowserConfigured(body: KotlinJsBrowserDsl.() -> Unit)
|
||||
}
|
||||
|
||||
interface KotlinJsIrTargetDsl {
|
||||
fun browser() = browser { }
|
||||
fun browser(body: KotlinJsIrBrowserDsl.() -> Unit)
|
||||
fun browser(fn: Closure<*>) {
|
||||
browser {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun nodejs() = nodejs { }
|
||||
fun nodejs(body: KotlinJsIrNodeDsl.() -> Unit)
|
||||
fun nodejs(fn: Closure<*>) {
|
||||
nodejs {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun produceKotlinLibrary()
|
||||
|
||||
fun produceExecutable()
|
||||
|
||||
val testRuns: NamedDomainObjectContainer<KotlinJsReportAggregatingTestRun>
|
||||
}
|
||||
|
||||
interface KotlinJsTargetDsl : KotlinTarget {
|
||||
fun browser() = browser { }
|
||||
fun browser(body: KotlinJsBrowserDsl.() -> Unit)
|
||||
|
||||
+2
-1
@@ -28,7 +28,8 @@ import javax.inject.Inject
|
||||
open class KotlinJsIrTarget @Inject constructor(project: Project, platformType: KotlinPlatformType) :
|
||||
KotlinOnlyTarget<KotlinJsIrCompilation>(project, platformType),
|
||||
KotlinTargetWithTests<JsAggregatingExecutionSource, KotlinJsReportAggregatingTestRun>,
|
||||
KotlinJsTargetDsl, KotlinJsSubtargetContainerDsl {
|
||||
KotlinJsTargetDsl,
|
||||
KotlinJsSubtargetContainerDsl {
|
||||
override lateinit var testRuns: NamedDomainObjectContainer<KotlinJsReportAggregatingTestRun>
|
||||
internal set
|
||||
|
||||
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.targets.js.ir
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.process.internal.DefaultProcessForkOptions
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecutionSpec
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.LoadNpmModules
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.karma.KotlinKarma
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.mocha.KotlinMocha
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTest
|
||||
import org.jetbrains.kotlin.gradle.utils.newFileProperty
|
||||
|
||||
open class KotlinJsIrTest :
|
||||
KotlinTest(),
|
||||
RequiresNpmDependencies,
|
||||
LoadNpmModules {
|
||||
private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject)
|
||||
|
||||
@get:Internal
|
||||
internal var testFramework: KotlinJsIrTestFramework? = null
|
||||
|
||||
@Suppress("unused")
|
||||
val testFrameworkSettings: String
|
||||
@Input get() = testFramework!!.settingsState
|
||||
|
||||
@Input
|
||||
var debug: Boolean = false
|
||||
|
||||
@Internal
|
||||
override lateinit var compilation: KotlinJsIrCompilation
|
||||
|
||||
@InputFile
|
||||
val inputFileProperty: RegularFileProperty = project.newFileProperty()
|
||||
|
||||
@Suppress("unused")
|
||||
val runtimeClasspath: FileCollection
|
||||
@InputFiles get() = compilation.runtimeDependencyFiles
|
||||
|
||||
@Suppress("unused")
|
||||
internal val compilationOutputs: FileCollection
|
||||
@InputFiles get() = compilation.output.allOutputs
|
||||
|
||||
@Suppress("unused")
|
||||
val compilationId: String
|
||||
@Input get() = compilation.let {
|
||||
val target = it.target
|
||||
target.project.path + "@" + target.name + ":" + it.compilationName
|
||||
}
|
||||
|
||||
override val nodeModulesToLoad: List<String>
|
||||
@Internal get() = listOf("./" + compilation.npmProject.main)
|
||||
|
||||
override val nodeModulesRequired: Boolean
|
||||
@Internal get() = testFramework!!.nodeModulesRequired
|
||||
|
||||
override val requiredNpmDependencies: Collection<RequiredKotlinJsDependency>
|
||||
@Internal get() = testFramework!!.requiredNpmDependencies
|
||||
|
||||
@Deprecated("Use useMocha instead", ReplaceWith("useMocha()"))
|
||||
fun useNodeJs() = useMocha()
|
||||
|
||||
@Deprecated("Use useMocha instead", ReplaceWith("useMocha(body)"))
|
||||
fun useNodeJs(body: KotlinMocha.() -> Unit) = useMocha(body)
|
||||
|
||||
@Deprecated("Use useMocha instead", ReplaceWith("useMocha(fn)"))
|
||||
fun useNodeJs(fn: Closure<*>) {
|
||||
useMocha {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun useMocha() = useMocha {}
|
||||
fun useMocha(body: KotlinMocha.() -> Unit) = use(KotlinMocha(compilation), body)
|
||||
fun useMocha(fn: Closure<*>) {
|
||||
useMocha {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
|
||||
fun useKarma() = useKarma {}
|
||||
fun useKarma(body: KotlinKarma.() -> Unit) = use(KotlinKarma(compilation), body)
|
||||
fun useKarma(fn: Closure<*>) {
|
||||
useKarma {
|
||||
ConfigureUtil.configure(fn, this)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <T : KotlinJsIrTestFramework> use(runner: T, body: T.() -> Unit): T {
|
||||
check(testFramework == null) {
|
||||
"testFramework already configured for task ${this.path}"
|
||||
}
|
||||
|
||||
val testFramework = runner.also(body)
|
||||
this.testFramework = testFramework
|
||||
|
||||
return testFramework
|
||||
}
|
||||
|
||||
override fun executeTests() {
|
||||
nodeJs.npmResolutionManager.checkRequiredDependencies(this)
|
||||
super.executeTests()
|
||||
}
|
||||
|
||||
override fun createTestExecutionSpec(): TCServiceMessagesTestExecutionSpec {
|
||||
val forkOptions = DefaultProcessForkOptions(fileResolver)
|
||||
forkOptions.workingDir = compilation.npmProject.dir
|
||||
forkOptions.executable = nodeJs.requireConfigured().nodeExecutable
|
||||
|
||||
val nodeJsArgs = mutableListOf<String>()
|
||||
|
||||
return testFramework!!.createTestExecutionSpec(
|
||||
task = this,
|
||||
forkOptions = forkOptions,
|
||||
nodeJsArgs = nodeJsArgs,
|
||||
debug = debug
|
||||
)
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.targets.js.ir
|
||||
|
||||
import org.gradle.process.ProcessForkOptions
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecutionSpec
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||
|
||||
interface KotlinJsIrTestFramework : RequiresNpmDependencies {
|
||||
val settingsState: String
|
||||
|
||||
fun createTestExecutionSpec(
|
||||
task: KotlinJsIrTest,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec
|
||||
|
||||
/* because KotlinJsTestFramework override it too
|
||||
override val nodeModulesRequired: Boolean
|
||||
get() = true
|
||||
*/
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.targets.js.npm
|
||||
|
||||
interface LoadNpmModules {
|
||||
val nodeModulesToLoad: List<String>
|
||||
}
|
||||
+2
-4
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecuti
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.LoadNpmModules
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.karma.KotlinKarma
|
||||
@@ -28,8 +27,7 @@ import org.jetbrains.kotlin.gradle.utils.newFileProperty
|
||||
|
||||
open class KotlinJsTest :
|
||||
KotlinTest(),
|
||||
RequiresNpmDependencies,
|
||||
LoadNpmModules {
|
||||
RequiresNpmDependencies {
|
||||
private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject)
|
||||
|
||||
@get:Internal
|
||||
@@ -63,7 +61,7 @@ open class KotlinJsTest :
|
||||
target.project.path + "@" + target.name + ":" + it.compilationName
|
||||
}
|
||||
|
||||
override val nodeModulesToLoad: List<String>
|
||||
val nodeModulesToLoad: List<String>
|
||||
@Internal get() = listOf("./" + compilation.npmProject.main)
|
||||
|
||||
override val nodeModulesRequired: Boolean
|
||||
|
||||
+2
-36
@@ -20,12 +20,8 @@ import org.jetbrains.kotlin.gradle.targets.js.NpmPackageVersion
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.appendConfigsFromDir
|
||||
import org.jetbrains.kotlin.gradle.targets.js.internal.parseNodeJsStackTraceAsJvm
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTest
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTestFramework
|
||||
import org.jetbrains.kotlin.gradle.targets.js.jsQuoted
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.LoadNpmModules
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
|
||||
@@ -35,8 +31,7 @@ import org.slf4j.Logger
|
||||
import java.io.File
|
||||
|
||||
class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
||||
KotlinJsTestFramework,
|
||||
KotlinJsIrTestFramework {
|
||||
KotlinJsTestFramework {
|
||||
private val project: Project = compilation.target.project
|
||||
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||
private val versions = nodeJs.versions
|
||||
@@ -276,41 +271,12 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
||||
return adapterJs
|
||||
}
|
||||
|
||||
override fun createTestExecutionSpec(
|
||||
task: KotlinJsIrTest,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec =
|
||||
createTestExecutionSpecPrivate(
|
||||
task = task,
|
||||
forkOptions = forkOptions,
|
||||
nodeJsArgs = nodeJsArgs,
|
||||
debug = debug
|
||||
)
|
||||
|
||||
override fun createTestExecutionSpec(
|
||||
task: KotlinJsTest,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec =
|
||||
createTestExecutionSpecPrivate(
|
||||
task = task,
|
||||
forkOptions = forkOptions,
|
||||
nodeJsArgs = nodeJsArgs,
|
||||
debug = debug
|
||||
)
|
||||
|
||||
private fun <T> createTestExecutionSpecPrivate(
|
||||
task: T,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec
|
||||
where T : KotlinTest,
|
||||
T : RequiresNpmDependencies,
|
||||
T : LoadNpmModules {
|
||||
): TCServiceMessagesTestExecutionSpec {
|
||||
val npmProject = compilation.npmProject
|
||||
|
||||
val file = task.nodeModulesToLoad
|
||||
|
||||
+2
-34
@@ -14,22 +14,16 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinGradleNpmPackage
|
||||
import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency
|
||||
import org.jetbrains.kotlin.gradle.targets.js.internal.parseNodeJsStackTraceAsJvm
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTest
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTestFramework
|
||||
import org.jetbrains.kotlin.gradle.targets.js.jsQuoted
|
||||
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.LoadNpmModules
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTestFramework
|
||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinTestRunnerCliArgs
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTest
|
||||
import java.io.File
|
||||
|
||||
class KotlinMocha(override val compilation: KotlinJsCompilation) :
|
||||
KotlinJsTestFramework,
|
||||
KotlinJsIrTestFramework {
|
||||
KotlinJsTestFramework {
|
||||
private val project: Project = compilation.target.project
|
||||
private val nodeJs = NodeJsRootPlugin.apply(project.rootProject)
|
||||
private val versions = nodeJs.versions
|
||||
@@ -47,38 +41,12 @@ class KotlinMocha(override val compilation: KotlinJsCompilation) :
|
||||
// https://mochajs.org/#-timeout-ms-t-ms
|
||||
var timeout: String = DEFAULT_TIMEOUT
|
||||
|
||||
override fun createTestExecutionSpec(
|
||||
task: KotlinJsIrTest,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec =
|
||||
createTestExecutionSpecPrivate<KotlinJsIrTest>(
|
||||
task, forkOptions, nodeJsArgs, debug
|
||||
)
|
||||
|
||||
override fun createTestExecutionSpec(
|
||||
task: KotlinJsTest,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec =
|
||||
createTestExecutionSpecPrivate(
|
||||
task = task,
|
||||
forkOptions = forkOptions,
|
||||
nodeJsArgs = nodeJsArgs,
|
||||
debug = debug
|
||||
)
|
||||
|
||||
private fun <T> createTestExecutionSpecPrivate(
|
||||
task: T,
|
||||
forkOptions: ProcessForkOptions,
|
||||
nodeJsArgs: MutableList<String>,
|
||||
debug: Boolean
|
||||
): TCServiceMessagesTestExecutionSpec
|
||||
where T : KotlinTest,
|
||||
T : RequiresNpmDependencies,
|
||||
T : LoadNpmModules {
|
||||
): TCServiceMessagesTestExecutionSpec {
|
||||
val clientSettings = TCServiceMessagesClientSettings(
|
||||
task.name,
|
||||
testNameSuffix = task.targetName,
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
implementation-class=org.jetbrains.kotlin.gradle.plugin.KotlinJsIrPluginWrapper
|
||||
Reference in New Issue
Block a user