Wizard: specify test platform to use on JVM
#KT-37965 fixed
This commit is contained in:
+3
@@ -15,6 +15,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
|
||||
+3
@@ -15,6 +15,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting
|
||||
|
||||
+3
@@ -16,6 +16,9 @@ kotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
withJava()
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
|
||||
+3
@@ -16,6 +16,9 @@ kotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
withJava()
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting
|
||||
|
||||
+3
@@ -15,6 +15,9 @@ dependencies {
|
||||
implementation project(':c')
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -17,6 +17,9 @@ dependencies {
|
||||
implementation(project(":c"))
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+3
@@ -15,6 +15,9 @@ dependencies {
|
||||
implementation project(':d')
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -17,6 +17,9 @@ dependencies {
|
||||
implementation(project(":d"))
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+3
@@ -14,6 +14,9 @@ dependencies {
|
||||
implementation project(':a')
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -16,6 +16,9 @@ dependencies {
|
||||
implementation(project(":a"))
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+3
@@ -14,6 +14,9 @@ dependencies {
|
||||
rootProject
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -16,6 +16,9 @@ dependencies {
|
||||
rootProject
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+3
@@ -14,6 +14,9 @@ dependencies {
|
||||
implementation project(':b')
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -16,6 +16,9 @@ dependencies {
|
||||
implementation(project(":b"))
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+8
@@ -60,6 +60,14 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.6'
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.6"
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = '9'
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
js('a', LEGACY) {
|
||||
browser {
|
||||
|
||||
+3
@@ -15,6 +15,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "9"
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
js("a", LEGACY) {
|
||||
browser {
|
||||
|
||||
+3
@@ -13,6 +13,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+3
@@ -14,6 +14,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
}
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
|
||||
+3
@@ -16,6 +16,9 @@ repositories {
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
}
|
||||
tasks.test {
|
||||
useJUnit()
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
+3
@@ -28,6 +28,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
js(LEGACY) {
|
||||
|
||||
+3
@@ -28,6 +28,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
js(LEGACY) {
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
|
||||
+3
@@ -15,6 +15,9 @@ kotlin {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
testRuns["test"].executionTask.configure {
|
||||
useJUnit()
|
||||
}
|
||||
}
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
|
||||
+6
@@ -13,6 +13,7 @@ object Versions {
|
||||
val GRADLE = version("6.3")
|
||||
val KTOR: (kotlinVersion: Version) -> Version = { kotlinVersion -> version("1.3.2-$kotlinVersion") }
|
||||
val JUNIT = version("4.12")
|
||||
val JUNIT5 = version("5.6.0")
|
||||
|
||||
object ANDROID {
|
||||
val ANDROID_MATERIAL = version("1.2.0")
|
||||
@@ -40,6 +41,11 @@ object Versions {
|
||||
object GRADLE_PLUGINS {
|
||||
val ANDROID = version("4.0.1")
|
||||
}
|
||||
|
||||
object MAVEN_PLUGINS {
|
||||
val SUREFIRE = version("2.22.2")
|
||||
val FAILSAFE = SUREFIRE
|
||||
}
|
||||
}
|
||||
|
||||
private fun version(version: String) = Version.fromString(version)
|
||||
+10
-9
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.MavenPrinter
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.ModulePath
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.SourcesetType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
|
||||
import java.util.*
|
||||
|
||||
interface DependencyIR : BuildSystemIR {
|
||||
val dependencyType: DependencyType
|
||||
@@ -26,7 +27,7 @@ data class ModuleDependencyIR(
|
||||
override fun withDependencyType(type: DependencyType): DependencyIR = copy(dependencyType = type)
|
||||
|
||||
override fun BuildFilePrinter.render() = when (this) {
|
||||
is GradlePrinter -> call(dependencyType.gradleName) {
|
||||
is GradlePrinter -> call(dependencyType.getGradleName()) {
|
||||
call("project", forceBrackets = true) {
|
||||
+path.parts.joinToString(separator = "") { ":$it" }.quotified
|
||||
}
|
||||
@@ -63,22 +64,22 @@ fun SourcesetType.toDependencyType() = when (this) {
|
||||
SourcesetType.test -> DependencyType.TEST
|
||||
}
|
||||
|
||||
val DependencyType.gradleName
|
||||
get() = when (this) {
|
||||
DependencyType.MAIN -> "implementation"
|
||||
DependencyType.TEST -> "testImplementation"
|
||||
}
|
||||
fun DependencyType.getGradleName(type: String = "implementation") = when (this) {
|
||||
DependencyType.MAIN -> type
|
||||
DependencyType.TEST -> "test${type.capitalize(Locale.US)}"
|
||||
}
|
||||
|
||||
data class ArtifactBasedLibraryDependencyIR(
|
||||
override val artifact: LibraryArtifact,
|
||||
override val version: Version,
|
||||
override val dependencyType: DependencyType
|
||||
override val dependencyType: DependencyType,
|
||||
val dependencyKind: String = "implementation"
|
||||
) : LibraryDependencyIR {
|
||||
override fun withDependencyType(type: DependencyType): ArtifactBasedLibraryDependencyIR =
|
||||
copy(dependencyType = type)
|
||||
|
||||
override fun BuildFilePrinter.render() = when (this) {
|
||||
is GradlePrinter -> call(dependencyType.gradleName) {
|
||||
is GradlePrinter -> call(dependencyType.getGradleName(dependencyKind)) {
|
||||
with(artifact) {
|
||||
when (this) {
|
||||
is MavenArtifact -> +"$groupId:$artifactId:${version}".quotified
|
||||
@@ -125,7 +126,7 @@ abstract class KotlinLibraryDependencyIR(
|
||||
|
||||
override fun BuildFilePrinter.render() {
|
||||
when (this) {
|
||||
is GradlePrinter -> call(dependencyType.gradleName) {
|
||||
is GradlePrinter -> call(dependencyType.getGradleName()) {
|
||||
if (GradlePrinter.GradleDsl.KOTLIN == dsl || isInMppModule) {
|
||||
+"kotlin("
|
||||
+artifactName.quotified
|
||||
|
||||
+2
@@ -42,6 +42,8 @@ class GradleIRListBuilder private constructor() : GradleIRBuilderBase {
|
||||
|
||||
operator fun String.unaryPlus() = RawGradleIR { +this@unaryPlus }.also(irs::add)
|
||||
operator fun BuildSystemIR.unaryPlus() = also(irs::add)
|
||||
operator fun Collection<BuildSystemIR>.unaryPlus() = also(irs::addAll)
|
||||
|
||||
fun addRaw(raw: GradlePrinter.() -> Unit) = RawGradleIR(raw).also(irs::add)
|
||||
fun addRaw(@NonNls raw: String) = RawGradleIR { +raw }.also(irs::add)
|
||||
|
||||
|
||||
+14
@@ -7,10 +7,12 @@ package org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.maven
|
||||
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemPluginIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.RepositoryWrapper
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.BuildFilePrinter
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.MavenPrinter
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repository
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
|
||||
|
||||
interface MavenIR : BuildSystemIR {
|
||||
fun MavenPrinter.renderMaven()
|
||||
@@ -31,6 +33,18 @@ data class PluginRepositoryMavenIR(
|
||||
}
|
||||
}
|
||||
|
||||
data class MavenOnlyPluginIR(
|
||||
val artifactId: String,
|
||||
val version: Version,
|
||||
) : MavenIR, BuildSystemPluginIR {
|
||||
override fun MavenPrinter.renderMaven() {
|
||||
node("plugin") {
|
||||
singleLineNode("artifactId") { +artifactId }
|
||||
singleLineNode("version") { +version.text }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class MavenPropertyIR(
|
||||
@NonNls val name: String,
|
||||
@NonNls val value: String
|
||||
|
||||
+5
@@ -196,6 +196,11 @@ object AndroidTargetConfigurator : TargetConfigurator,
|
||||
)
|
||||
}
|
||||
|
||||
override fun createBuildFileIRs(reader: Reader, configurationData: ModulesToIrConversionData, module: Module): List<BuildSystemIR> =
|
||||
buildList {
|
||||
+super<AndroidModuleConfigurator>.createBuildFileIRs(reader, configurationData, module)
|
||||
+super<ModuleConfiguratorWithTests>.createBuildFileIRs(reader, configurationData, module)
|
||||
}
|
||||
|
||||
val androidPlugin by enumSetting<AndroidGradlePlugin>(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.android.setting.android.plugin"),
|
||||
|
||||
+62
-20
@@ -7,20 +7,22 @@ package org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators
|
||||
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.KotlinNewProjectWizardBundle
|
||||
import org.jetbrains.kotlin.tools.projectWizard.Versions
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Reader
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.ModuleConfiguratorSettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.safeAs
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.BuildSystemIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.DependencyType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.KotlinArbitraryDependencyIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.irsList
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.maven.MavenOnlyPluginIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.library.MavenArtifact
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.buildSystemType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModuleType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModulesToIrConversionData
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.ModuleKind
|
||||
|
||||
@@ -54,59 +56,99 @@ interface ModuleConfiguratorWithTests : ModuleConfiguratorWithSettings {
|
||||
reader: Reader,
|
||||
configurationData: ModulesToIrConversionData,
|
||||
module: Module
|
||||
): List<BuildSystemIR> =
|
||||
inContextOfModuleConfigurator(module) {
|
||||
reader {
|
||||
testFramework.reference.settingValue.dependencyNames.map { dependencyName ->
|
||||
KotlinArbitraryDependencyIR(
|
||||
dependencyName,
|
||||
isInMppModule = module.kind
|
||||
.let { it == ModuleKind.multiplatform || it == ModuleKind.target },
|
||||
kotlinVersion = KotlinPlugin.version.propertyValue,
|
||||
dependencyType = DependencyType.TEST
|
||||
)
|
||||
): List<BuildSystemIR> = irsList {
|
||||
val testFramework = inContextOfModuleConfigurator(module) { reader { testFramework.reference.settingValue } }
|
||||
|
||||
testFramework.dependencyNames.forEach { dependencyName ->
|
||||
+KotlinArbitraryDependencyIR(
|
||||
dependencyName,
|
||||
isInMppModule = module.kind
|
||||
.let { it == ModuleKind.multiplatform || it == ModuleKind.target },
|
||||
kotlinVersion = reader { KotlinPlugin.version.propertyValue },
|
||||
dependencyType = DependencyType.TEST
|
||||
)
|
||||
}
|
||||
testFramework.additionalDependencies.forEach { +it }
|
||||
}
|
||||
|
||||
override fun createBuildFileIRs(reader: Reader, configurationData: ModulesToIrConversionData, module: Module) = irsList {
|
||||
val testFramework = inContextOfModuleConfigurator(module) { reader { testFramework.reference.settingValue } }
|
||||
val buildSystemType = reader { buildSystemType }
|
||||
if (testFramework != KotlinTestFramework.NONE) {
|
||||
when {
|
||||
module.kind.isSingleplatform && buildSystemType.isGradle -> {
|
||||
testFramework.usePlatform?.let { usePlatform ->
|
||||
val testTaskAccess = if (buildSystemType == BuildSystemType.GradleKotlinDsl) "tasks.test" else "test"
|
||||
testTaskAccess {
|
||||
+"$usePlatform()"
|
||||
}
|
||||
}
|
||||
}
|
||||
buildSystemType == BuildSystemType.Maven -> {
|
||||
+MavenOnlyPluginIR("maven-surefire-plugin", Versions.MAVEN_PLUGINS.SUREFIRE)
|
||||
+MavenOnlyPluginIR("maven-failsafe-plugin", Versions.MAVEN_PLUGINS.FAILSAFE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> = listOf(testFramework)
|
||||
}
|
||||
|
||||
|
||||
enum class KotlinTestFramework(
|
||||
override val text: String,
|
||||
val moduleTypes: List<ModuleType>,
|
||||
val dependencyNames: List<String>
|
||||
val usePlatform: String?,
|
||||
val dependencyNames: List<String>,
|
||||
val additionalDependencies: List<LibraryDependencyIR> = emptyList()
|
||||
) : DisplayableSettingItem {
|
||||
NONE(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.tests.setting.framework.none"),
|
||||
ModuleType.ALL.toList(),
|
||||
usePlatform = null,
|
||||
emptyList()
|
||||
),
|
||||
JUNIT4(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.tests.setting.framework.junit4"),
|
||||
listOf(ModuleType.jvm, ModuleType.android),
|
||||
usePlatform = "useJUnit",
|
||||
listOf("test-junit")
|
||||
),
|
||||
JUNIT5(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.tests.setting.framework.junit5"),
|
||||
listOf(ModuleType.jvm),
|
||||
listOf("test-junit5")
|
||||
usePlatform = "useJUnitPlatform",
|
||||
dependencyNames = listOf("test-junit5"),
|
||||
additionalDependencies = listOf(
|
||||
ArtifactBasedLibraryDependencyIR(
|
||||
MavenArtifact(DefaultRepository.MAVEN_CENTRAL, "org.junit.jupiter", "junit-jupiter-api"),
|
||||
version = Versions.JUNIT5,
|
||||
dependencyType = DependencyType.TEST,
|
||||
),
|
||||
ArtifactBasedLibraryDependencyIR(
|
||||
MavenArtifact(DefaultRepository.MAVEN_CENTRAL, "org.junit.jupiter", "junit-jupiter-engine"),
|
||||
version = Versions.JUNIT5,
|
||||
dependencyType = DependencyType.TEST,
|
||||
dependencyKind = "runtimeOnly"
|
||||
),
|
||||
)
|
||||
),
|
||||
TEST_NG(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.tests.setting.framework.test.ng"),
|
||||
listOf(ModuleType.jvm),
|
||||
usePlatform = "useTestNG",
|
||||
listOf("test-testng")
|
||||
),
|
||||
JS(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.tests.setting.framework.js"),
|
||||
listOf(ModuleType.js),
|
||||
usePlatform = null,
|
||||
listOf("test-js")
|
||||
),
|
||||
COMMON(
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.tests.setting.framework.common"),
|
||||
listOf(ModuleType.common),
|
||||
usePlatform = null,
|
||||
listOf("test-common", "test-annotations-common")
|
||||
)
|
||||
}
|
||||
|
||||
+9
-5
@@ -29,13 +29,17 @@ class RealNativeTargetConfigurator private constructor(
|
||||
override val isIosTarget: Boolean
|
||||
get() = moduleSubType.isIOS
|
||||
|
||||
override fun createInnerTargetIrs(reader: Reader, module: Module): List<BuildSystemIR> = if (moduleSubType.isIOS) irsList {
|
||||
"binaries" {
|
||||
"framework" {
|
||||
"baseName" assign const(module.parent!!.name)
|
||||
override fun createInnerTargetIrs(reader: Reader, module: Module): List<BuildSystemIR> = irsList {
|
||||
+super<SimpleTargetConfigurator>.createInnerTargetIrs(reader, module)
|
||||
if (moduleSubType.isIOS) {
|
||||
"binaries" {
|
||||
"framework" {
|
||||
"baseName" assign const(module.parent!!.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else emptyList()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
val configurators = ModuleSubType.values()
|
||||
|
||||
+10
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.buildSystemType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.isGradle
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModuleSubType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ModulesToIrConversionData
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.ModuleKind
|
||||
@@ -162,6 +163,7 @@ object JvmTargetConfigurator : JvmModuleConfigurator,
|
||||
reader: Reader,
|
||||
module: Module
|
||||
): List<BuildSystemIR> = irsList {
|
||||
+super<SimpleTargetConfigurator>.createInnerTargetIrs(reader, module)
|
||||
reader {
|
||||
inContextOfModuleConfigurator(module) {
|
||||
val targetVersionValue = JvmModuleConfigurator.targetJvmVersion.reference.settingValue.value
|
||||
@@ -175,6 +177,14 @@ object JvmTargetConfigurator : JvmModuleConfigurator,
|
||||
"withJava"()
|
||||
}
|
||||
}
|
||||
val testFramework = inContextOfModuleConfigurator(module) { ModuleConfiguratorWithTests.testFramework.reference.settingValue }
|
||||
if (testFramework != KotlinTestFramework.NONE) {
|
||||
testFramework.usePlatform?.let { usePlatform ->
|
||||
"testRuns[\"test\"].executionTask.configure" {
|
||||
+"$usePlatform()"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -90,6 +90,7 @@ object JvmSinglePlatformModuleConfigurator : JvmModuleConfigurator,
|
||||
module: Module
|
||||
): List<BuildSystemIR> =
|
||||
buildList {
|
||||
+super<JvmModuleConfigurator>.createBuildFileIRs(reader, configurationData, module)
|
||||
if (configurationData.buildSystemType == BuildSystemType.GradleKotlinDsl) {
|
||||
+GradleImportIR("org.jetbrains.kotlin.gradle.tasks.KotlinCompile")
|
||||
}
|
||||
|
||||
+8
-7
@@ -17,19 +17,20 @@ import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.Template
|
||||
|
||||
@Suppress("EnumEntryName")
|
||||
enum class ModuleKind : DisplayableSettingItem {
|
||||
multiplatform,
|
||||
target,
|
||||
singleplatformJvm,
|
||||
singleplatformAndroid,
|
||||
singleplatformJsBrowser,
|
||||
singleplatformJsNode,
|
||||
enum class ModuleKind(val isSingleplatform: Boolean) : DisplayableSettingItem {
|
||||
multiplatform(isSingleplatform = false),
|
||||
target(isSingleplatform = false),
|
||||
singleplatformJvm(isSingleplatform = true),
|
||||
singleplatformAndroid(isSingleplatform = true),
|
||||
singleplatformJsBrowser(isSingleplatform = true),
|
||||
singleplatformJsNode(isSingleplatform = true),
|
||||
;
|
||||
|
||||
override val text: String
|
||||
get() = name
|
||||
}
|
||||
|
||||
|
||||
// TODO separate to classes
|
||||
class Module(
|
||||
@NonNls var name: String,
|
||||
|
||||
Reference in New Issue
Block a user