Wizard: add test infrastructure, project importing tests & project templates tests
This commit is contained in:
+34
-23
@@ -2,46 +2,57 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.YamlSettingsParser
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.ReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PluginSettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PluginSetting
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.IdeaIndependentWizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.Services
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.Path
|
||||
|
||||
class YamlWizard(
|
||||
private val yaml: String,
|
||||
private val path: String,
|
||||
private val projectPath: Path,
|
||||
createPlugins: (Context) -> List<Plugin>,
|
||||
servicesManager: ServicesManager = CLI_SERVICES_MANAGER,
|
||||
isUnitTestMode: Boolean
|
||||
) : Wizard(
|
||||
createPlugins,
|
||||
ServicesManager(Services.IDEA_INDEPENDENT_SERVICES) { services ->
|
||||
services.firstOrNull { it is IdeaIndependentWizardService }
|
||||
}, isUnitTestMode
|
||||
) {
|
||||
) : Wizard(createPlugins, servicesManager, isUnitTestMode) {
|
||||
private val settingsWritingContext = SettingsWritingContext(context, servicesManager, isUnitTestMode)
|
||||
|
||||
override fun apply(
|
||||
services: List<WizardService>,
|
||||
phases: Set<GenerationPhase>,
|
||||
onTaskExecuting: (PipelineTask) -> Unit
|
||||
): TaskResult<Unit> = computeM {
|
||||
super.apply(services, setOf(GenerationPhase.PREPARE), onTaskExecuting)
|
||||
val parsingData = with(valuesReadingContext) {
|
||||
ParsingState(TemplatesPlugin::templates.propertyValue, emptyMap())
|
||||
val (settingsValuesFromYaml) = valuesReadingContext.parseYaml(yaml, pluginSettings)
|
||||
|
||||
with(settingsWritingContext) {
|
||||
settingsValuesFromYaml.forEach { (reference, value) -> reference.setValue(value) }
|
||||
StructurePlugin::projectPath.reference.setValue(projectPath)
|
||||
}
|
||||
val yamlParser = YamlSettingsParser(pluginSettings, parsingData)
|
||||
val (settingsValuesFromYaml) = yamlParser.parseYamlText(yaml)
|
||||
val settingValues = defaultPluginSettingValues + settingsValuesFromYaml
|
||||
settingValues.forEach { (path, value) -> context.settingContext[path] = value }
|
||||
context.settingContext[StructurePlugin::projectPath.reference] = Paths.get(path)
|
||||
|
||||
super.apply(services, phases, onTaskExecuting)
|
||||
}
|
||||
|
||||
private val defaultPluginSettingValues
|
||||
get() = pluginSettings.mapNotNull { setting ->
|
||||
val defaultValue = setting.defaultValue ?: return@mapNotNull null
|
||||
PluginSettingReference(setting) to defaultValue
|
||||
}.toMap()
|
||||
companion object {
|
||||
val CLI_SERVICES_MANAGER = ServicesManager(Services.IDEA_INDEPENDENT_SERVICES) { services ->
|
||||
services.firstOrNull { it is IdeaIndependentWizardService }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ReadingContext.parseYaml(
|
||||
yaml: String,
|
||||
pluginSettings: List<PluginSetting<*, *>>
|
||||
): TaskResult<Map<SettingReference<*, *>, Any>> {
|
||||
val parsingData = ParsingState(TemplatesPlugin::templates.propertyValue, emptyMap())
|
||||
val yamlParser = YamlSettingsParser(pluginSettings, parsingData)
|
||||
return yamlParser.parseYamlText(yaml)
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.namespace == 'com.android' || requested.id.name == 'kotlin-android-extensions') {
|
||||
useModule('com.android.tools.build:gradle:3.5.2')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = 'generatedProject'
|
||||
|
||||
|
||||
include(':android')
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.namespace == "com.android" || requested.id.name == "kotlin-android-extensions") {
|
||||
useModule("com.android.tools.build:gradle:3.5.2")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = "generatedProject"
|
||||
|
||||
|
||||
include(":android")
|
||||
+1
-5
@@ -6,8 +6,4 @@ kotlin:
|
||||
- type:
|
||||
name: android
|
||||
androidSdkPath: /home/user/Android/Sdk
|
||||
kind: singleplatformJvm
|
||||
name: android
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
name: android
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+1
-10
@@ -2,20 +2,11 @@ kotlin:
|
||||
projectKind: Multiplatform
|
||||
modules:
|
||||
- type: multiplatform
|
||||
kind: multiplatform
|
||||
name: a
|
||||
subModules:
|
||||
- type: jsNode
|
||||
kind: target
|
||||
name: nodeJs
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
- type:
|
||||
name: jsBrowser
|
||||
testFramework: JS
|
||||
kind: target
|
||||
name: browser
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
name: browser
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+1
-6
@@ -2,15 +2,10 @@ kotlin:
|
||||
projectKind: Multiplatform
|
||||
modules:
|
||||
- type: multiplatform
|
||||
kind: multiplatform
|
||||
name: a
|
||||
subModules:
|
||||
- type:
|
||||
targetJvmVersion: "1.8"
|
||||
name: jvmTarget
|
||||
testFramework: JUNIT4
|
||||
kind: target
|
||||
name: jvm
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
name: jvm
|
||||
+1
@@ -0,0 +1 @@
|
||||
// runForMaven true
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+1
-5
@@ -5,8 +5,4 @@ kotlin:
|
||||
targetJvmVersion: "1.6"
|
||||
name: JVM Module
|
||||
testFramework: JUNIT4
|
||||
name: nya
|
||||
kind: singleplatformJvm
|
||||
sourcesets:
|
||||
- type: main
|
||||
|
||||
name: nya
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+1
-6
@@ -2,12 +2,7 @@ kotlin:
|
||||
projectKind: Multiplatform
|
||||
modules:
|
||||
- type: multiplatform
|
||||
kind: multiplatform
|
||||
name: a
|
||||
subModules:
|
||||
- type: nativeForCurrentSystem
|
||||
kind: target
|
||||
name: myNative
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
name: myNative
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+1
-10
@@ -2,23 +2,14 @@ kotlin:
|
||||
projectKind: Multiplatform
|
||||
modules:
|
||||
- type: multiplatform
|
||||
kind: multiplatform
|
||||
name: a
|
||||
subModules:
|
||||
- type:
|
||||
targetJvmVersion: "9"
|
||||
name: jvmTarget
|
||||
testFramework: JUNIT4
|
||||
kind: target
|
||||
name: jvm
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
- type:
|
||||
name: jsBrowser
|
||||
testFramework: JS
|
||||
kind: target
|
||||
name: a
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
name: a
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+1
-6
@@ -2,12 +2,7 @@ kotlin:
|
||||
projectKind: Multiplatform
|
||||
modules:
|
||||
- type: multiplatform
|
||||
kind: multiplatform
|
||||
name: a
|
||||
subModules:
|
||||
- type: linuxX64Target
|
||||
kind: target
|
||||
name: linuxX64
|
||||
sourcesets:
|
||||
- type: main
|
||||
- type: test
|
||||
name: linuxX64
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.js' version '1.3.61'
|
||||
}
|
||||
group = 'testGroupId'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
|
||||
}
|
||||
kotlin.target.browser { }
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
kotlin("js") version "1.3.61"
|
||||
}
|
||||
group = "testGroupId"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-js"))
|
||||
implementation(kotlin("stdlib-js"))
|
||||
}
|
||||
kotlin.target.browser { }
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'generatedProject'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "generatedProject"
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
kotlin:
|
||||
projectKind: js
|
||||
modules:
|
||||
- type: jsSinglepaltform
|
||||
name: a
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android' version '1.3.61'
|
||||
id 'kotlin-android-extensions'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
implementation 'androidx.core:core-ktx:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7'
|
||||
}
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
defaultConfig {
|
||||
applicationId 'me.user.app'
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName '1.0'
|
||||
}
|
||||
buildTypes {
|
||||
'release' {
|
||||
minifyEnabled false
|
||||
}
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
kotlin("android") version "1.3.61"
|
||||
id("kotlin-android-extensions")
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
implementation("androidx.core:core-ktx:1.1.0")
|
||||
implementation("androidx.appcompat:appcompat:1.1.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
|
||||
implementation(kotlin("stdlib-jdk7"))
|
||||
}
|
||||
android {
|
||||
compileSdkVersion(29)
|
||||
defaultConfig {
|
||||
applicationId = "me.user.app"
|
||||
minSdkVersion(24)
|
||||
targetSdkVersion(29)
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.namespace == 'com.android' || requested.id.name == 'kotlin-android-extensions') {
|
||||
useModule('com.android.tools.build:gradle:3.5.2')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = 'AndroidApplication'
|
||||
|
||||
|
||||
include(':app')
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.namespace == "com.android" || requested.id.name == "kotlin-android-extensions") {
|
||||
useModule("com.android.tools.build:gradle:3.5.2")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = "AndroidApplication"
|
||||
|
||||
|
||||
include(":app")
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
android:
|
||||
androidSdkPath: android.sdk
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-common')
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.3.61"
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-common"))
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'EmptyMultiplatform'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "EmptyMultiplatform"
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||
}
|
||||
tasks.withType(KotlinCompile) {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.3.61"
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
// runForMaven true
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mainModule</artifactId>
|
||||
<groupId>me.user</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mainModule</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<kotlin.code.style>official</kotlin.code.style>
|
||||
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>mavenCentral</id>
|
||||
<url>https://repo1.maven.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>1.3.61</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>1.3.61</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>1.3.61</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'EmptySingleplatform'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "EmptySingleplatform"
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.js' version '1.3.61'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
url 'https://dl.bintray.com/kotlin/kotlin-js-wrappers'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-html-js:0.6.12'
|
||||
implementation 'org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60'
|
||||
implementation 'org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60'
|
||||
implementation npm('react','16.12.0')
|
||||
implementation npm('react-dom','16.12.0')
|
||||
implementation npm('react-is','16.12.0')
|
||||
implementation 'org.jetbrains:kotlin-styled:1.0.0-pre.89-kotlin-1.3.60'
|
||||
implementation npm('styled-components','5.0.0')
|
||||
implementation npm('inline-style-prefixer','5.1.0')
|
||||
}
|
||||
kotlin.target.browser { }
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
plugins {
|
||||
kotlin("js") version "1.3.61"
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-js"))
|
||||
implementation(kotlin("stdlib-js"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.6.12")
|
||||
implementation("org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60")
|
||||
implementation("org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60")
|
||||
implementation(npm("react","16.12.0"))
|
||||
implementation(npm("react-dom","16.12.0"))
|
||||
implementation(npm("react-is","16.12.0"))
|
||||
implementation("org.jetbrains:kotlin-styled:1.0.0-pre.89-kotlin-1.3.60")
|
||||
implementation(npm("styled-components","5.0.0"))
|
||||
implementation(npm("inline-style-prefixer","5.1.0"))
|
||||
}
|
||||
kotlin.target.browser { }
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'JsBrowserApplication'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "JsBrowserApplication"
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
|
||||
id 'application'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||
}
|
||||
tasks.withType(KotlinCompile) {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
application {
|
||||
mainClassName = 'MainKt'
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.3.61"
|
||||
application
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
testImplementation(kotlin("test-junit"))
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
tasks.withType<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
application {
|
||||
mainClassName = "MainKt"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
// runForMaven true
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>consoleApp</artifactId>
|
||||
<groupId>me.user</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>consoleApp</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<kotlin.code.style>official</kotlin.code.style>
|
||||
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>mavenCentral</id>
|
||||
<url>https://repo1.maven.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>1.3.61</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<configuration>
|
||||
<mainClass>MainKt</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit</artifactId>
|
||||
<version>1.3.61</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>1.3.61</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'JvmConsoleApplication'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "JvmConsoleApplication"
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
|
||||
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
|
||||
id 'application'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
url 'https://dl.bintray.com/kotlin/ktor'
|
||||
}
|
||||
maven {
|
||||
url 'https://dl.bintray.com/kotlin/kotlin-js-wrappers'
|
||||
}
|
||||
}
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
js {
|
||||
browser {
|
||||
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-jdk8')
|
||||
implementation 'io.ktor:ktor-server-netty:1.2.6'
|
||||
implementation 'io.ktor:ktor-html-builder:1.2.6'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.12'
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-js')
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-html-js:0.6.12'
|
||||
implementation 'org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60'
|
||||
implementation 'org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60'
|
||||
implementation npm('react','16.12.0')
|
||||
implementation npm('react-dom','16.12.0')
|
||||
implementation npm('react-is','16.12.0')
|
||||
implementation 'org.jetbrains:kotlin-styled:1.0.0-pre.89-kotlin-1.3.60'
|
||||
implementation npm('styled-components','5.0.0')
|
||||
implementation npm('inline-style-prefixer','5.1.0')
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-js')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
application {
|
||||
mainClassName = 'ServerKt'
|
||||
}
|
||||
tasks.getByName('jsBrowserProductionWebpack') {
|
||||
outputFileName = 'output.js'
|
||||
}
|
||||
tasks.getByName('jvmJar') {
|
||||
dependsOn(tasks.getByName('jsBrowserProductionWebpack'))
|
||||
def jsBrowserProductionWebpack = tasks.getByName('jsBrowserProductionWebpack')
|
||||
from(new File(jsBrowserProductionWebpack.destinationDirectory, jsBrowserProductionWebpack.outputFileName))
|
||||
}
|
||||
tasks.getByName('run') {
|
||||
dependsOn(tasks.getByName('jvmJar'))
|
||||
classpath(tasks.getByName('jvmJar'))
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.3.61"
|
||||
application
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
url = uri("https://dl.bintray.com/kotlin/ktor")
|
||||
}
|
||||
maven {
|
||||
url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers")
|
||||
}
|
||||
}
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
js {
|
||||
browser {
|
||||
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
implementation("io.ktor:ktor-server-netty:1.2.6")
|
||||
implementation("io.ktor:ktor-html-builder:1.2.6")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.12")
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit"))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-js"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.6.12")
|
||||
implementation("org.jetbrains:kotlin-react:16.9.0-pre.89-kotlin-1.3.60")
|
||||
implementation("org.jetbrains:kotlin-react-dom:16.9.0-pre.89-kotlin-1.3.60")
|
||||
implementation(npm("react","16.12.0"))
|
||||
implementation(npm("react-dom","16.12.0"))
|
||||
implementation(npm("react-is","16.12.0"))
|
||||
implementation("org.jetbrains:kotlin-styled:1.0.0-pre.89-kotlin-1.3.60")
|
||||
implementation(npm("styled-components","5.0.0"))
|
||||
implementation(npm("inline-style-prefixer","5.1.0"))
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
application {
|
||||
mainClassName = "ServerKt"
|
||||
}
|
||||
tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack") {
|
||||
outputFileName = "output.js"
|
||||
}
|
||||
tasks.getByName<Jar>("jvmJar") {
|
||||
dependsOn(tasks.getByName("jsBrowserProductionWebpack"))
|
||||
val jsBrowserProductionWebpack = tasks.getByName<KotlinWebpack>("jsBrowserProductionWebpack")
|
||||
from(File(jsBrowserProductionWebpack.destinationDirectory, jsBrowserProductionWebpack.outputFileName))
|
||||
}
|
||||
tasks.getByName<JavaExec>("run") {
|
||||
dependsOn(tasks.getByName<Jar>("jvmJar"))
|
||||
classpath(tasks.getByName<Jar>("jvmJar"))
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'JvmServerJsClient'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "JvmServerJsClient"
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests
|
||||
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
js {
|
||||
browser {
|
||||
|
||||
}
|
||||
}
|
||||
def hostOs = System.getProperty("os.name")
|
||||
def isMingwX64 = hostOs.startsWith("Windows")
|
||||
KotlinNativeTargetWithTests nativeTarget
|
||||
if (hostOs == "Mac OS X") nativeTarget = macosX64('native')
|
||||
else if (hostOs == "Linux") nativeTarget = linuxX64("native")
|
||||
else if (isMingwX64) nativeTarget = mingwX64("native")
|
||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
||||
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-common')
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-common')
|
||||
implementation kotlin('test-annotations-common')
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-jdk8')
|
||||
}
|
||||
}
|
||||
jvmTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-junit')
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib-js')
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation kotlin('test-js')
|
||||
}
|
||||
}
|
||||
nativeMain {
|
||||
|
||||
}
|
||||
nativeTest {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.3.61"
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
js {
|
||||
browser {
|
||||
|
||||
}
|
||||
}
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
val nativeTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("native")
|
||||
hostOs == "Linux" -> linuxX64("native")
|
||||
isMingwX64 -> mingwX64("native")
|
||||
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-common"))
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-common"))
|
||||
implementation(kotlin("test-annotations-common"))
|
||||
}
|
||||
}
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit"))
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib-js"))
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
val nativeMain by getting
|
||||
val nativeTest by getting
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'MultiplatformLibrary'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "MultiplatformLibrary"
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests
|
||||
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
|
||||
}
|
||||
group = 'me.user'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
def hostOs = System.getProperty("os.name")
|
||||
def isMingwX64 = hostOs.startsWith("Windows")
|
||||
KotlinNativeTargetWithTests nativeTarget
|
||||
if (hostOs == "Mac OS X") nativeTarget = macosX64('native')
|
||||
else if (hostOs == "Linux") nativeTarget = linuxX64("native")
|
||||
else if (isMingwX64) nativeTarget = mingwX64("native")
|
||||
else throw new GradleException("Host OS is not supported in Kotlin/Native.")
|
||||
|
||||
nativeTarget.with {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = 'main'
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
nativeMain {
|
||||
|
||||
}
|
||||
nativeTest {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.3.61"
|
||||
}
|
||||
group = "me.user"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
kotlin {
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
val nativeTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("native")
|
||||
hostOs == "Linux" -> linuxX64("native")
|
||||
isMingwX64 -> mingwX64("native")
|
||||
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
|
||||
}
|
||||
|
||||
nativeTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "main"
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
val nativeMain by getting
|
||||
val nativeTest by getting
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = 'NativeConsoleApplication'
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "NativeConsoleApplication"
|
||||
+8
-53
@@ -6,21 +6,17 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.cli
|
||||
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ExceptionError
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.div
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.onFailure
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.Services
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.Plugins
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.MavenPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle.GroovyDslPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle.KotlinDslPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.YamlWizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
|
||||
abstract fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard
|
||||
|
||||
fun doTest(directoryPath: String) {
|
||||
val directory = Paths.get(directoryPath)
|
||||
val expectedDirectory = expectedDirectory(directory)
|
||||
@@ -33,67 +29,26 @@ abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
|
||||
}
|
||||
|
||||
private fun doTest(directory: Path, buildSystem: BuildSystem) {
|
||||
val yaml = directory.resolve("settings.yaml").toFile().readText() + "\n" +
|
||||
defaultStructure + "\n" +
|
||||
buildSystem.yaml
|
||||
val tempDir = Files.createTempDirectory(null)
|
||||
val wizard = YamlWizard(yaml, tempDir.toString(), Plugins.allPlugins, isUnitTestMode = true)
|
||||
val tempDirectory = Files.createTempDirectory(null)
|
||||
val wizard = createWizard(directory, buildSystem, tempDirectory)
|
||||
val result = wizard.apply(Services.IDEA_INDEPENDENT_SERVICES, GenerationPhase.ALL)
|
||||
result.onFailure { errors ->
|
||||
errors.forEach { error ->
|
||||
if (error is ExceptionError) {
|
||||
throw error.exception
|
||||
}
|
||||
}
|
||||
fail(errors.joinToString("\n"))
|
||||
}
|
||||
result.assertSuccess()
|
||||
|
||||
val expectedDirectory = expectedDirectory(directory)
|
||||
|
||||
compareFiles(
|
||||
expectedDirectory.allBuildFiles(buildSystem), expectedDirectory,
|
||||
tempDir.allBuildFiles(buildSystem), tempDir
|
||||
tempDirectory.allBuildFiles(buildSystem), tempDirectory
|
||||
)
|
||||
}
|
||||
|
||||
private fun Path.allBuildFiles(buildSystem: BuildSystem) =
|
||||
listFiles { it.fileName.toString() == buildSystem.buildFileName }
|
||||
|
||||
private enum class BuildSystem(val buildFileName: String, val yaml: String) {
|
||||
GRADLE_KOTLIN_DSL(
|
||||
buildFileName = "build.gradle.kts",
|
||||
yaml = """buildSystem:
|
||||
type: GradleKotlinDsl
|
||||
gradle:
|
||||
createGradleWrapper: false
|
||||
version: 5.4.1""".trimIndent()
|
||||
),
|
||||
GRADLE_GROOVY_DSL(
|
||||
buildFileName = "build.gradle",
|
||||
yaml = """buildSystem:
|
||||
type: GradleGroovyDsl
|
||||
gradle:
|
||||
createGradleWrapper: false
|
||||
version: 5.4.1""".trimIndent()
|
||||
),
|
||||
MAVEN(
|
||||
buildFileName = "pom.xml",
|
||||
yaml = """buildSystem:
|
||||
type: Maven""".trimIndent()
|
||||
)
|
||||
}
|
||||
listFiles { it.fileName.toString() in buildSystem.allBuildFileNames }
|
||||
|
||||
private fun expectedDirectory(directory: Path): Path =
|
||||
(directory / EXPECTED_DIRECTORY_NAME).takeIf { Files.exists(it) } ?: directory
|
||||
|
||||
companion object {
|
||||
private const val EXPECTED_DIRECTORY_NAME = "expected"
|
||||
|
||||
private val defaultStructure =
|
||||
"""structure:
|
||||
name: generatedProject
|
||||
groupId: testGroupId
|
||||
artifactId: testArtifactId
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tools.projectWizard.cli
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.YamlWizard
|
||||
import java.nio.file.Path
|
||||
|
||||
abstract class AbstractProjectTemplateBuildFileGenerationTest : AbstractBuildFileGenerationTest() {
|
||||
override fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard =
|
||||
ProjectTemplateBasedTestWizard.createByDirectory(directory, buildSystem, projectDirectory, YamlWizard.CLI_SERVICES_MANAGER)
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tools.projectWizard.cli
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.Plugins
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.YamlWizard
|
||||
import java.nio.file.Path
|
||||
|
||||
abstract class AbstractYamlBuildFileGenerationTest : AbstractBuildFileGenerationTest() {
|
||||
override fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard {
|
||||
val yaml = readSettingsYaml(directory, buildSystem) ?: error("settings.yaml should exists in $directory")
|
||||
return YamlWizard(yaml, projectDirectory.toString(), Plugins.allPlugins, isUnitTestMode = true)
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tools.projectWizard.cli
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.TaskResult
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.compute
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.computeM
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.context.SettingsWritingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.Plugins
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.applyProjectTemplate
|
||||
import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.YamlWizard
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.parseYaml
|
||||
import java.nio.file.Path
|
||||
|
||||
class ProjectTemplateBasedTestWizard(
|
||||
private val projectTemplate: ProjectTemplate,
|
||||
private val buildSystem: BuildSystem,
|
||||
private val projectDirectory: Path,
|
||||
servicesManager: ServicesManager,
|
||||
private val additionalYamlSettings: String?
|
||||
) : Wizard(
|
||||
Plugins.allPlugins,
|
||||
servicesManager,
|
||||
isUnitTestMode = true
|
||||
) {
|
||||
private val settingsWritingContext = SettingsWritingContext(context, servicesManager, isUnitTestMode = true)
|
||||
|
||||
override fun apply(
|
||||
services: List<WizardService>,
|
||||
phases: Set<GenerationPhase>,
|
||||
onTaskExecuting: (PipelineTask) -> Unit
|
||||
): TaskResult<Unit> =
|
||||
computeM {
|
||||
super.apply(services, setOf(GenerationPhase.PREPARE), onTaskExecuting).ensure()
|
||||
with(settingsWritingContext) {
|
||||
applyProjectTemplate(projectTemplate)
|
||||
BuildSystemPlugin::type.reference.setValue(buildSystem.buildSystemType)
|
||||
StructurePlugin::projectPath.reference.setValue(projectDirectory)
|
||||
StructurePlugin::name.reference.setValue(projectTemplate.id)
|
||||
StructurePlugin::groupId.reference.setValue(GROUP_ID)
|
||||
StructurePlugin::artifactId.reference.setValue(ARTIFACT_ID)
|
||||
applyAdditionalSettingsFromYaml().ensure()
|
||||
}
|
||||
|
||||
super.apply(services, phases, onTaskExecuting)
|
||||
}
|
||||
|
||||
private fun SettingsWritingContext.applyAdditionalSettingsFromYaml() = compute {
|
||||
if (additionalYamlSettings != null) {
|
||||
val (additionalSettings) = parseYaml(additionalYamlSettings, pluginSettings)
|
||||
additionalSettings.forEach { (reference, value) -> reference.setValue(value) }
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val GROUP_ID = "me.user"
|
||||
private const val ARTIFACT_ID = "artifactId"
|
||||
|
||||
fun createByDirectory(
|
||||
directory: Path,
|
||||
buildSystem: BuildSystem,
|
||||
projectDirectory: Path,
|
||||
servicesManager: ServicesManager
|
||||
): ProjectTemplateBasedTestWizard {
|
||||
val projectTemplateId = directory.fileName.toString()
|
||||
val projectTemplate = ProjectTemplate.byId(projectTemplateId)
|
||||
?: error("Directory name should be a valid template id but was $projectTemplateId")
|
||||
val additionalYamlSettings = readSettingsYamlWithoutDefaultStructure(directory)
|
||||
return ProjectTemplateBasedTestWizard(projectTemplate, buildSystem, projectDirectory, servicesManager, additionalYamlSettings)
|
||||
}
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tools.projectWizard.cli;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ProjectTemplateBuildFileGenerationTestGenerated extends AbstractProjectTemplateBuildFileGenerationTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInProjectTemplatesBuildFileGeneration() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration"), Pattern.compile("^([^\\.]+)$"), null, false);
|
||||
}
|
||||
|
||||
@TestMetadata("androidApplication")
|
||||
public void testAndroidApplication() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/androidApplication/");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyMultiplatform")
|
||||
public void testEmptyMultiplatform() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/emptyMultiplatform/");
|
||||
}
|
||||
|
||||
@TestMetadata("emptySingleplatform")
|
||||
public void testEmptySingleplatform() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/emptySingleplatform/");
|
||||
}
|
||||
|
||||
@TestMetadata("jsBrowserApplication")
|
||||
public void testJsBrowserApplication() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/jsBrowserApplication/");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmConsoleApplication")
|
||||
public void testJvmConsoleApplication() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/jvmConsoleApplication/");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmServerJsClient")
|
||||
public void testJvmServerJsClient() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/jvmServerJsClient/");
|
||||
}
|
||||
|
||||
@TestMetadata("multiplatformLibrary")
|
||||
public void testMultiplatformLibrary() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/multiplatformLibrary/");
|
||||
}
|
||||
|
||||
@TestMetadata("nativeConsoleApplication")
|
||||
public void testNativeConsoleApplication() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration/nativeConsoleApplication/");
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tools.projectWizard.cli
|
||||
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KParameter
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
|
||||
interface TestParameters {
|
||||
companion object {
|
||||
inline fun <reified T : TestParameters> fromTestDataOrDefault(
|
||||
directory: Path,
|
||||
parametersFileName: String = "parameters.txt"
|
||||
): T =
|
||||
fromTestData(directory, parametersFileName, T::class) ?: T::class.DEFAULT_VALUE
|
||||
|
||||
val <T : TestParameters> KClass<T>.DEFAULT_VALUE
|
||||
get() = primaryConstructorOrError.callBy(emptyMap())
|
||||
|
||||
fun <T : TestParameters> fromTestData(directory: Path, parametersFileName: String, klass: KClass<T>): T? {
|
||||
val file = directory.resolve(parametersFileName)
|
||||
if (!Files.exists(file) || !Files.isRegularFile(file)) return null
|
||||
val text = file.readFile()
|
||||
return parseTestParameters(text, klass)
|
||||
}
|
||||
|
||||
private fun <T : TestParameters> parseTestParameters(text: String, klass: KClass<T>): T {
|
||||
val constructor = klass.primaryConstructorOrError
|
||||
val parameters = constructor.parameters.associateWith { parameter ->
|
||||
parameter.parseValue(text)
|
||||
}
|
||||
return constructor.callBy(parameters)
|
||||
}
|
||||
|
||||
private fun KParameter.parseValue(text: String): Any? = when (type.classifier as? KClass<*>) {
|
||||
Boolean::class -> InTextDirectivesUtils.getPrefixedBoolean(text, name) ?: false
|
||||
else -> error("Invalid test parameter $name with type $type")
|
||||
}
|
||||
|
||||
private val <T : Any> KClass<T>.primaryConstructorOrError
|
||||
get() = primaryConstructor ?: error("Primary constructor should present")
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.tools.projectWizard.cli
|
||||
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
|
||||
interface TestWizardService : WizardService {
|
||||
}
|
||||
+6
-1
@@ -19,7 +19,7 @@ import java.util.regex.Pattern;
|
||||
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class BuildFileGenerationTestGenerated extends AbstractBuildFileGenerationTest {
|
||||
public class YamlBuildFileGenerationTestGenerated extends AbstractYamlBuildFileGenerationTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
@@ -62,4 +62,9 @@ public class BuildFileGenerationTestGenerated extends AbstractBuildFileGeneratio
|
||||
public void testSimpleNativeTarget() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/simpleNativeTarget/");
|
||||
}
|
||||
|
||||
@TestMetadata("singleplatformJs")
|
||||
public void testSingleplatformJs() throws Exception {
|
||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/singleplatformJs/");
|
||||
}
|
||||
}
|
||||
+75
@@ -5,8 +5,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.cli
|
||||
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import org.hamcrest.core.Is
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ExceptionError
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.TaskResult
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.onFailure
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType
|
||||
import org.junit.Assert.assertThat
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
@@ -34,4 +39,74 @@ internal fun compareFiles(
|
||||
for ((actualFile, expectedFile) in actualFilesSorted zip expectedFilesSorted) {
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile.toFile(), actualFile.readFile())
|
||||
}
|
||||
}
|
||||
|
||||
fun readSettingsYaml(directory: Path, buildSystem: BuildSystem): String? =
|
||||
readSettingsYamlWithoutDefaultStructure(directory)?.let { text ->
|
||||
text + "\n" +
|
||||
defaultStructure + "\n" +
|
||||
buildSystem.yaml
|
||||
}
|
||||
|
||||
fun readSettingsYamlWithoutDefaultStructure(directory: Path): String? =
|
||||
directory.resolve("settings.yaml").takeIf { Files.exists(it) }?.readFile()
|
||||
|
||||
|
||||
enum class BuildSystem(
|
||||
val buildFileName: String,
|
||||
val additionalFileNames: List<String> = emptyList(),
|
||||
val yaml: String
|
||||
) {
|
||||
GRADLE_KOTLIN_DSL(
|
||||
buildFileName = "build.gradle.kts",
|
||||
additionalFileNames = listOf("settings.gradle.kts"),
|
||||
yaml = """buildSystem:
|
||||
type: GradleKotlinDsl
|
||||
gradle:
|
||||
version: 5.4.1""".trimIndent()
|
||||
),
|
||||
GRADLE_GROOVY_DSL(
|
||||
buildFileName = "build.gradle",
|
||||
additionalFileNames = listOf("settings.gradle"),
|
||||
yaml = """buildSystem:
|
||||
type: GradleGroovyDsl
|
||||
gradle:
|
||||
version: 5.4.1""".trimIndent()
|
||||
),
|
||||
MAVEN(
|
||||
buildFileName = "pom.xml",
|
||||
yaml = """buildSystem:
|
||||
type: Maven""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
val BuildSystem.buildSystemType
|
||||
get() = when (this) {
|
||||
BuildSystem.GRADLE_KOTLIN_DSL -> BuildSystemType.GradleKotlinDsl
|
||||
BuildSystem.GRADLE_GROOVY_DSL -> BuildSystemType.GradleGroovyDsl
|
||||
BuildSystem.MAVEN -> BuildSystemType.Maven
|
||||
}
|
||||
|
||||
val BuildSystem.allBuildFileNames
|
||||
get() = additionalFileNames + buildFileName
|
||||
|
||||
val BuildSystem.isGradle
|
||||
get() = this == BuildSystem.GRADLE_KOTLIN_DSL || this == BuildSystem.GRADLE_GROOVY_DSL
|
||||
|
||||
private val defaultStructure =
|
||||
"""structure:
|
||||
name: generatedProject
|
||||
groupId: testGroupId
|
||||
artifactId: testArtifactId
|
||||
""".trimIndent()
|
||||
|
||||
fun TaskResult<Any>.assertSuccess() {
|
||||
onFailure { errors ->
|
||||
errors.forEach { error ->
|
||||
if (error is ExceptionError) {
|
||||
throw error.exception
|
||||
}
|
||||
}
|
||||
UsefulTestCase.fail(errors.joinToString("\n"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user