Wizard: add test infrastructure, project importing tests & project templates tests
This commit is contained in:
+2
-1
@@ -670,7 +670,8 @@ tasks {
|
|||||||
dependsOn("dist")
|
dependsOn("dist")
|
||||||
dependsOn(
|
dependsOn(
|
||||||
":libraries:tools:new-project-wizard:test",
|
":libraries:tools:new-project-wizard:test",
|
||||||
":libraries:tools:new-project-wizard:new-project-wizard-cli:test"
|
":libraries:tools:new-project-wizard:new-project-wizard-cli:test",
|
||||||
|
":idea:idea-new-project-wizard:test"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,10 +163,13 @@ import org.jetbrains.kotlin.search.AbstractAnnotatedMembersSearchTest
|
|||||||
import org.jetbrains.kotlin.search.AbstractInheritorsSearchTest
|
import org.jetbrains.kotlin.search.AbstractInheritorsSearchTest
|
||||||
import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest
|
import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest
|
||||||
import org.jetbrains.kotlin.test.TargetBackend
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.cli.AbstractBuildFileGenerationTest
|
import org.jetbrains.kotlin.tools.projectWizard.cli.AbstractProjectTemplateBuildFileGenerationTest
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.AbstractYamlBuildFileGenerationTest
|
||||||
import org.jetbrains.kotlinx.serialization.AbstractSerializationIrBytecodeListingTest
|
import org.jetbrains.kotlinx.serialization.AbstractSerializationIrBytecodeListingTest
|
||||||
import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginBytecodeListingTest
|
import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginBytecodeListingTest
|
||||||
import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginDiagnosticTest
|
import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginDiagnosticTest
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.AbstractProjectTemplateNewWizardProjectImportTest
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.AbstractYamlNewWizardProjectImportTest
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
System.setProperty("java.awt.headless", "true")
|
System.setProperty("java.awt.headless", "true")
|
||||||
@@ -1092,9 +1095,35 @@ fun main(args: Array<String>) {
|
|||||||
"libraries/tools/new-project-wizard/new-project-wizard-cli/tests",
|
"libraries/tools/new-project-wizard/new-project-wizard-cli/tests",
|
||||||
"libraries/tools/new-project-wizard/new-project-wizard-cli/testData"
|
"libraries/tools/new-project-wizard/new-project-wizard-cli/testData"
|
||||||
) {
|
) {
|
||||||
testClass<AbstractBuildFileGenerationTest> {
|
testClass<AbstractYamlBuildFileGenerationTest> {
|
||||||
model("buildFileGeneration", recursive = false, extension = null)
|
model("buildFileGeneration", recursive = false, extension = null)
|
||||||
}
|
}
|
||||||
|
testClass<AbstractProjectTemplateBuildFileGenerationTest> {
|
||||||
|
model("projectTemplatesBuildFileGeneration", recursive = false, extension = null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testGroup(
|
||||||
|
"idea/idea-new-project-wizard/tests",
|
||||||
|
"libraries/tools/new-project-wizard/new-project-wizard-cli/testData"
|
||||||
|
) {
|
||||||
|
fun TestGroup.TestClass.allBuildSystemTests(relativeRootPath: String) {
|
||||||
|
for (testClass in listOf("GradleKts", "GradleGroovy", "Maven")) {
|
||||||
|
model(
|
||||||
|
relativeRootPath,
|
||||||
|
recursive = false,
|
||||||
|
extension = null,
|
||||||
|
testMethod = "doTest${testClass}",
|
||||||
|
testClassName = testClass
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testClass<AbstractYamlNewWizardProjectImportTest> {
|
||||||
|
allBuildSystemTests("buildFileGeneration")
|
||||||
|
}
|
||||||
|
testClass<AbstractProjectTemplateNewWizardProjectImportTest> {
|
||||||
|
allBuildSystemTests("projectTemplatesBuildFileGeneration")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: move these tests into idea-completion module
|
//TODO: move these tests into idea-completion module
|
||||||
|
|||||||
@@ -14,6 +14,16 @@ dependencies {
|
|||||||
compileOnly(intellijDep())
|
compileOnly(intellijDep())
|
||||||
compileOnly(intellijPluginDep("gradle"))
|
compileOnly(intellijPluginDep("gradle"))
|
||||||
|
|
||||||
|
testImplementation(projectTests(":idea"))
|
||||||
|
testImplementation(project(":libraries:tools:new-project-wizard:new-project-wizard-cli"))
|
||||||
|
testImplementation(projectTests(":libraries:tools:new-project-wizard:new-project-wizard-cli"))
|
||||||
|
testImplementation(projectTests(":compiler:tests-common"))
|
||||||
|
testImplementation(project(":kotlin-test:kotlin-test-junit"))
|
||||||
|
testImplementation(commonDep("junit:junit"))
|
||||||
|
testImplementation(intellijDep())
|
||||||
|
testImplementation(intellijPluginDep("gradle"))
|
||||||
|
|
||||||
|
|
||||||
excludeInAndroidStudio(rootProject) {
|
excludeInAndroidStudio(rootProject) {
|
||||||
compileOnly(intellijPluginDep("maven"))
|
compileOnly(intellijPluginDep("maven"))
|
||||||
}
|
}
|
||||||
@@ -25,6 +35,7 @@ dependencies {
|
|||||||
Platform[192].orHigher {
|
Platform[192].orHigher {
|
||||||
compileOnly(intellijPluginDep("java")) { includeJars("java-api", "java-impl") }
|
compileOnly(intellijPluginDep("java")) { includeJars("java-api", "java-impl") }
|
||||||
testCompileOnly(intellijPluginDep("java")) { includeJars("java-api", "java-impl") }
|
testCompileOnly(intellijPluginDep("java")) { includeJars("java-api", "java-impl") }
|
||||||
|
testRuntimeOnly(intellijPluginDep("java")) { includeJars("java-api") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +44,8 @@ sourceSets {
|
|||||||
"test" { projectDefault() }
|
"test" { projectDefault() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testsJar()
|
||||||
|
|
||||||
projectTest {
|
projectTest {
|
||||||
dependsOn(":dist")
|
dependsOn(":dist")
|
||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
|
|||||||
+2
-1
@@ -34,7 +34,8 @@ class IdeaGradleWizardService(private val project: Project) : ProjectImportingWi
|
|||||||
// to import Gradle project in all IDEAs from 183 to 193
|
// to import Gradle project in all IDEAs from 183 to 193
|
||||||
override fun importProject(
|
override fun importProject(
|
||||||
path: Path,
|
path: Path,
|
||||||
modulesIrs: List<ModuleIR>
|
modulesIrs: List<ModuleIR>,
|
||||||
|
buildSystem: BuildSystemType
|
||||||
): TaskResult<Unit> = performImport(path) andThen createGradleWrapper(path)
|
): TaskResult<Unit> = performImport(path) andThen createGradleWrapper(path)
|
||||||
|
|
||||||
private fun performImport(path: Path) = safe {
|
private fun performImport(path: Path) = safe {
|
||||||
|
|||||||
+5
-1
@@ -36,7 +36,11 @@ class IdeaJpsWizardService(
|
|||||||
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
||||||
buildSystemType == BuildSystemType.Jps
|
buildSystemType == BuildSystemType.Jps
|
||||||
|
|
||||||
override fun importProject(path: Path, modulesIrs: List<ModuleIR>): TaskResult<Unit> = runWriteAction {
|
override fun importProject(
|
||||||
|
path: Path,
|
||||||
|
modulesIrs: List<ModuleIR>,
|
||||||
|
buildSystem: BuildSystemType
|
||||||
|
): TaskResult<Unit> = runWriteAction {
|
||||||
ProjectImporter(project, modulesModel, path, modulesIrs)
|
ProjectImporter(project, modulesModel, path, modulesIrs)
|
||||||
.import()
|
.import()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -20,7 +20,8 @@ class IdeaMavenWizardService(private val project: Project) : ProjectImportingWiz
|
|||||||
|
|
||||||
override fun importProject(
|
override fun importProject(
|
||||||
path: Path,
|
path: Path,
|
||||||
modulesIrs: List<ModuleIR>
|
modulesIrs: List<ModuleIR>,
|
||||||
|
buildSystem: BuildSystemType
|
||||||
): TaskResult<Unit> = safe {
|
): TaskResult<Unit> = safe {
|
||||||
MavenProjectImporter(project).importProject(path)
|
MavenProjectImporter(project).importProject(path)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -20,10 +20,10 @@ object IdeaServices {
|
|||||||
IdeaSettingSavingWizardService()
|
IdeaSettingSavingWizardService()
|
||||||
)
|
)
|
||||||
|
|
||||||
fun createScopeDependent(project: Project, model: ModifiableModuleModel) = listOf(
|
fun createScopeDependent(project: Project, model: ModifiableModuleModel?) = listOfNotNull(
|
||||||
IdeaGradleWizardService(project),
|
IdeaGradleWizardService(project),
|
||||||
IdeaMavenWizardService(project),
|
IdeaMavenWizardService(project),
|
||||||
IdeaJpsWizardService(project, model),
|
model?.let { IdeaJpsWizardService(project, it) },
|
||||||
IdeaFileFormattingService(project),
|
IdeaFileFormattingService(project),
|
||||||
IdeaRunConfigurationsService(project)
|
IdeaRunConfigurationsService(project)
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -88,5 +88,5 @@ abstract class UIComponent<V : Any>(
|
|||||||
|
|
||||||
fun <V : Any> ReadingContext.valueForSetting(
|
fun <V : Any> ReadingContext.valueForSetting(
|
||||||
uiComponent: UIComponent<V>,
|
uiComponent: UIComponent<V>,
|
||||||
setting: Setting<V, SettingType<V>>
|
setting: SettingReference<V, SettingType<V>>
|
||||||
): V? = setting.savedOrDefaultValue ?: uiComponent.getUiValue()
|
): V? = setting.savedOrDefaultValue ?: uiComponent.getUiValue()
|
||||||
+3
-6
@@ -8,6 +8,7 @@ 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.entity.reference
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.ProjectTemplatesPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.ProjectTemplatesPlugin
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.applyProjectTemplate
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate
|
import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.IdeContext
|
||||||
@@ -57,12 +58,8 @@ class TemplatesSubStep(ideContext: IdeContext) : SubStep(ideContext) {
|
|||||||
|
|
||||||
private fun applySelectedTemplate() {
|
private fun applySelectedTemplate() {
|
||||||
modify {
|
modify {
|
||||||
projectTemplateSettingComponent.value?.setsValues?.forEach { (setting, value) ->
|
val selectedProjectTemplate = projectTemplateSettingComponent.value ?: return@modify
|
||||||
setting.setValue(value)
|
applyProjectTemplate(selectedProjectTemplate)
|
||||||
}
|
|
||||||
allModules().forEach { module ->
|
|
||||||
module.apply { initDefaultValuesForSettings() }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -62,7 +62,6 @@ class NewModuleCreator {
|
|||||||
}
|
}
|
||||||
val createdModule = Module(
|
val createdModule = Module(
|
||||||
name,
|
name,
|
||||||
configurator.moduleKind,
|
|
||||||
configurator,
|
configurator,
|
||||||
template = null,
|
template = null,
|
||||||
sourcesets = sourcesets,
|
sourcesets = sourcesets,
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ class VersionSettingComponent(
|
|||||||
|
|
||||||
override fun onInit() {
|
override fun onInit() {
|
||||||
super.onInit()
|
super.onInit()
|
||||||
val values = read { setting.savedOrDefaultValue }?.let(::listOf).orEmpty()
|
val values = read { reference.savedOrDefaultValue }?.let(::listOf).orEmpty()
|
||||||
comboBox.model = DefaultComboBoxModel<Version>(values.toTypedArray())
|
comboBox.model = DefaultComboBoxModel<Version>(values.toTypedArray())
|
||||||
|
|
||||||
if (values.isNotEmpty()) {
|
if (values.isNotEmpty()) {
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ abstract class UIComponentDelegatingSettingComponent<V : Any, T : SettingType<V>
|
|||||||
override fun onInit() {
|
override fun onInit() {
|
||||||
super.onInit()
|
super.onInit()
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
read { valueForSetting(uiComponent, setting) }?.let { value = it }
|
read { valueForSetting(uiComponent, reference) }?.let { value = it }
|
||||||
}
|
}
|
||||||
value?.let(uiComponent::updateUiValue)
|
value?.let(uiComponent::updateUiValue)
|
||||||
}
|
}
|
||||||
|
|||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard
|
||||||
|
|
||||||
|
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||||
|
import com.intellij.openapi.projectRoots.ProjectJdkTable
|
||||||
|
import com.intellij.openapi.projectRoots.SimpleJavaSdkType
|
||||||
|
import com.intellij.testFramework.IdeaTestUtil
|
||||||
|
import com.intellij.testFramework.PlatformTestCase
|
||||||
|
import org.jetbrains.kotlin.test.testFramework.runWriteAction
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.*
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.Services
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.service.IdeaServices
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.service.IdeaWizardService
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.services.TestWizardServices
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
|
import org.jetbrains.plugins.gradle.settings.DistributionType
|
||||||
|
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings
|
||||||
|
import org.jetbrains.plugins.gradle.settings.GradleSettings
|
||||||
|
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||||
|
import org.jetbrains.plugins.gradle.util.GradleEnvironment
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
|
//TODO change to HeavyPlatformTestCase when we stop supporting <= 192
|
||||||
|
abstract class AbstractNewWizardProjectImportTest : PlatformTestCase() {
|
||||||
|
abstract fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
runWriteAction {
|
||||||
|
val sdk = SimpleJavaSdkType().createJdk(SDK_NAME, IdeaTestUtil.requireRealJdkHome())
|
||||||
|
ProjectJdkTable.getInstance().addJdk(sdk, project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun tearDown() {
|
||||||
|
super.tearDown()
|
||||||
|
runWriteAction {
|
||||||
|
ProjectJdkTable.getInstance().findJdk(SDK_NAME)?.let(ProjectJdkTable.getInstance()::removeJdk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun doTestGradleKts(directoryPath: String) {
|
||||||
|
doTest(directoryPath, BuildSystem.GRADLE_KOTLIN_DSL)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun doTestGradleGroovy(directoryPath: String) {
|
||||||
|
doTest(directoryPath, BuildSystem.GRADLE_GROOVY_DSL)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun doTestMaven(directoryPath: String) {
|
||||||
|
doTest(directoryPath, BuildSystem.MAVEN)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doTest(directoryPath: String, buildSystem: BuildSystem) {
|
||||||
|
val directory = Paths.get(directoryPath)
|
||||||
|
|
||||||
|
val parameters = ProjectImportingTestParameters.fromTestDataOrDefault(directory)
|
||||||
|
if (!parameters.runForMaven && buildSystem == BuildSystem.MAVEN) return
|
||||||
|
|
||||||
|
val tempDirectory = Files.createTempDirectory(null)
|
||||||
|
if (buildSystem.isGradle) {
|
||||||
|
prepareGradleBuildSystem(tempDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
|
val wizard = createWizard(directory, buildSystem, tempDirectory)
|
||||||
|
|
||||||
|
val projectDependentServices =
|
||||||
|
IdeaServices.createScopeDependent(project, null) +
|
||||||
|
TestWizardServices.createProjectDependent(project) +
|
||||||
|
TestWizardServices.PROJECT_INDEPENDENT
|
||||||
|
wizard.apply(projectDependentServices, GenerationPhase.ALL).assertSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prepareGradleBuildSystem(directory: Path) {
|
||||||
|
project.getService(GradleSettings::class.java)?.apply {
|
||||||
|
gradleVmOptions = GradleEnvironment.Headless.GRADLE_VM_OPTIONS ?: gradleVmOptions
|
||||||
|
isOfflineWork = GradleEnvironment.Headless.GRADLE_OFFLINE?.toBoolean() ?: isOfflineWork
|
||||||
|
serviceDirectoryPath = GradleEnvironment.Headless.GRADLE_SERVICE_DIRECTORY ?: serviceDirectoryPath
|
||||||
|
storeProjectFilesExternally = true
|
||||||
|
}
|
||||||
|
|
||||||
|
val settings = GradleProjectSettings().apply {
|
||||||
|
externalProjectPath = directory.toString()
|
||||||
|
isUseAutoImport = false
|
||||||
|
isUseQualifiedModuleNames = true
|
||||||
|
gradleJvm = SDK_NAME
|
||||||
|
distributionType = DistributionType.WRAPPED
|
||||||
|
}
|
||||||
|
ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID).linkProject(settings)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val SDK_NAME = "defaultSdk"
|
||||||
|
|
||||||
|
val IDE_WIZARD_TEST_SERVICES_MANAGER = ServicesManager(
|
||||||
|
IdeaServices.PROJECT_INDEPENDENT + Services.IDEA_INDEPENDENT_SERVICES
|
||||||
|
) { services ->
|
||||||
|
services.firstIsInstanceOrNull<TestWizardService>()
|
||||||
|
?: services.firstIsInstanceOrNull<IdeaWizardService>()
|
||||||
|
?: services.firstOrNull()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.BuildSystem
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.ProjectTemplateBasedTestWizard
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.readSettingsYaml
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.Plugins
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
abstract class AbstractProjectTemplateNewWizardProjectImportTest : AbstractNewWizardProjectImportTest() {
|
||||||
|
override fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard =
|
||||||
|
ProjectTemplateBasedTestWizard.createByDirectory(directory, buildSystem, projectDirectory, IDE_WIZARD_TEST_SERVICES_MANAGER)
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.BuildSystem
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.readSettingsYaml
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.Plugins
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
abstract class AbstractYamlNewWizardProjectImportTest : AbstractNewWizardProjectImportTest() {
|
||||||
|
override fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard {
|
||||||
|
val yaml = readSettingsYaml(directory, buildSystem) ?: error("settings.yaml does not exists in $directory")
|
||||||
|
return YamlWizard(
|
||||||
|
yaml = yaml,
|
||||||
|
projectPath = projectDirectory,
|
||||||
|
createPlugins = Plugins.allPlugins,
|
||||||
|
servicesManager = IDE_WIZARD_TEST_SERVICES_MANAGER,
|
||||||
|
isUnitTestMode = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
+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.wizard
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.TestParameters
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
data class ProjectImportingTestParameters(val runForMaven: Boolean = false) : TestParameters {
|
||||||
|
companion object {
|
||||||
|
fun fromTestDataOrDefault(directory: Path): ProjectImportingTestParameters =
|
||||||
|
TestParameters.fromTestDataOrDefault(directory, PARAMETERS_FILE_NAME)
|
||||||
|
|
||||||
|
private const val PARAMETERS_FILE_NAME = "importParameters.txt"
|
||||||
|
}
|
||||||
|
}
|
||||||
+179
@@ -0,0 +1,179 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard;
|
||||||
|
|
||||||
|
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")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class ProjectTemplateNewWizardProjectImportTestGenerated extends AbstractProjectTemplateNewWizardProjectImportTest {
|
||||||
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class GradleKts extends AbstractProjectTemplateNewWizardProjectImportTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTestGradleKts, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInGradleKts() 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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class GradleGroovy extends AbstractProjectTemplateNewWizardProjectImportTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTestGradleGroovy, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInGradleGroovy() 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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/projectTemplatesBuildFileGeneration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Maven extends AbstractProjectTemplateNewWizardProjectImportTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTestMaven, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMaven() 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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+179
@@ -0,0 +1,179 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard;
|
||||||
|
|
||||||
|
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")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class YamlNewWizardProjectImportTestGenerated extends AbstractYamlNewWizardProjectImportTest {
|
||||||
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class GradleKts extends AbstractYamlNewWizardProjectImportTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTestGradleKts, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInGradleKts() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration"), Pattern.compile("^([^\\.]+)$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("android")
|
||||||
|
public void testAndroid() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/android/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsNodeAndBrowserTargets")
|
||||||
|
public void testJsNodeAndBrowserTargets() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/jsNodeAndBrowserTargets/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmTarget")
|
||||||
|
public void testJvmTarget() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/jvmTarget/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinJvm")
|
||||||
|
public void testKotlinJvm() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/kotlinJvm/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeForCurrentSystem")
|
||||||
|
public void testNativeForCurrentSystem() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/nativeForCurrentSystem/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleMultiplatform")
|
||||||
|
public void testSimpleMultiplatform() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/simpleMultiplatform/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleNativeTarget")
|
||||||
|
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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class GradleGroovy extends AbstractYamlNewWizardProjectImportTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTestGradleGroovy, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInGradleGroovy() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration"), Pattern.compile("^([^\\.]+)$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("android")
|
||||||
|
public void testAndroid() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/android/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsNodeAndBrowserTargets")
|
||||||
|
public void testJsNodeAndBrowserTargets() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/jsNodeAndBrowserTargets/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmTarget")
|
||||||
|
public void testJvmTarget() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/jvmTarget/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinJvm")
|
||||||
|
public void testKotlinJvm() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/kotlinJvm/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeForCurrentSystem")
|
||||||
|
public void testNativeForCurrentSystem() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/nativeForCurrentSystem/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleMultiplatform")
|
||||||
|
public void testSimpleMultiplatform() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/simpleMultiplatform/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleNativeTarget")
|
||||||
|
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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class Maven extends AbstractYamlNewWizardProjectImportTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doTestMaven, this, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInMaven() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration"), Pattern.compile("^([^\\.]+)$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("android")
|
||||||
|
public void testAndroid() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/android/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsNodeAndBrowserTargets")
|
||||||
|
public void testJsNodeAndBrowserTargets() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/jsNodeAndBrowserTargets/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmTarget")
|
||||||
|
public void testJvmTarget() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/jvmTarget/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kotlinJvm")
|
||||||
|
public void testKotlinJvm() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/kotlinJvm/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeForCurrentSystem")
|
||||||
|
public void testNativeForCurrentSystem() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/nativeForCurrentSystem/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleMultiplatform")
|
||||||
|
public void testSimpleMultiplatform() throws Exception {
|
||||||
|
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/simpleMultiplatform/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simpleNativeTarget")
|
||||||
|
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/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard.services
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.TestWizardService
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.FileFormattingService
|
||||||
|
|
||||||
|
class FormattingTestWizardService : FileFormattingService, TestWizardService {
|
||||||
|
override fun formatFile(text: String, filename: String): String = text
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.wizard.services
|
||||||
|
|
||||||
|
import com.intellij.openapi.components.ServiceManager
|
||||||
|
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder
|
||||||
|
import com.intellij.openapi.externalSystem.model.DataNode
|
||||||
|
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||||
|
import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode
|
||||||
|
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback
|
||||||
|
import com.intellij.openapi.externalSystem.service.project.ProjectDataManager
|
||||||
|
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import org.jetbrains.kotlin.idea.framework.MAVEN_SYSTEM_ID
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.TestWizardService
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.Failure
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.ProjectImportingError
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.TaskResult
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.UNIT_SUCCESS
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.ProjectImportingWizardService
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.ModuleIR
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.isGradle
|
||||||
|
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
class GradleProjectImportingTestWizardService(private val project: Project) : ProjectImportingWizardService, TestWizardService {
|
||||||
|
override fun isSuitableFor(buildSystemType: BuildSystemType): Boolean =
|
||||||
|
buildSystemType.isGradle || buildSystemType == BuildSystemType.Maven
|
||||||
|
|
||||||
|
override fun importProject(
|
||||||
|
path: Path,
|
||||||
|
modulesIrs: List<ModuleIR>,
|
||||||
|
buildSystem: BuildSystemType
|
||||||
|
): TaskResult<Unit> {
|
||||||
|
var importingErrorMessage: String? = null
|
||||||
|
|
||||||
|
ExternalSystemUtil.refreshProjects(
|
||||||
|
ImportSpecBuilder(project, buildSystem.externalSystemId() ?: error("Unsupported build system $buildSystem"))
|
||||||
|
.use(ProgressExecutionMode.MODAL_SYNC)
|
||||||
|
.callback(object : ExternalProjectRefreshCallback {
|
||||||
|
override fun onSuccess(externalProject: DataNode<ProjectData>?) {
|
||||||
|
if (externalProject == null) {
|
||||||
|
importingErrorMessage = "Got null External project after import"
|
||||||
|
} else {
|
||||||
|
ServiceManager.getService(ProjectDataManager::class.java).importData(externalProject, project, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFailure(errorMessage: String, errorDetails: String?) {
|
||||||
|
importingErrorMessage = errorMessage
|
||||||
|
}
|
||||||
|
}).forceWhenUptodate()
|
||||||
|
)
|
||||||
|
|
||||||
|
return importingErrorMessage?.let { Failure(ProjectImportingError(it)) } ?: UNIT_SUCCESS
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun BuildSystemType.externalSystemId() = when (this) {
|
||||||
|
BuildSystemType.GradleKotlinDsl -> GradleConstants.SYSTEM_ID
|
||||||
|
BuildSystemType.GradleGroovyDsl -> GradleConstants.SYSTEM_ID
|
||||||
|
BuildSystemType.Jps -> null
|
||||||
|
BuildSystemType.Maven -> MAVEN_SYSTEM_ID
|
||||||
|
}
|
||||||
|
}
|
||||||
+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.wizard.services
|
||||||
|
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.cli.TestWizardService
|
||||||
|
|
||||||
|
object TestWizardServices {
|
||||||
|
fun createProjectDependent(project: Project): List<TestWizardService> = listOf(
|
||||||
|
GradleProjectImportingTestWizardService(project)
|
||||||
|
)
|
||||||
|
val PROJECT_INDEPENDENT = listOf(FormattingTestWizardService())
|
||||||
|
}
|
||||||
+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.YamlSettingsParser
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
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.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.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.phases.GenerationPhase
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Path
|
||||||
|
|
||||||
class YamlWizard(
|
class YamlWizard(
|
||||||
private val yaml: String,
|
private val yaml: String,
|
||||||
private val path: String,
|
private val projectPath: Path,
|
||||||
createPlugins: (Context) -> List<Plugin>,
|
createPlugins: (Context) -> List<Plugin>,
|
||||||
|
servicesManager: ServicesManager = CLI_SERVICES_MANAGER,
|
||||||
isUnitTestMode: Boolean
|
isUnitTestMode: Boolean
|
||||||
) : Wizard(
|
) : Wizard(createPlugins, servicesManager, isUnitTestMode) {
|
||||||
createPlugins,
|
private val settingsWritingContext = SettingsWritingContext(context, servicesManager, isUnitTestMode)
|
||||||
ServicesManager(Services.IDEA_INDEPENDENT_SERVICES) { services ->
|
|
||||||
services.firstOrNull { it is IdeaIndependentWizardService }
|
|
||||||
}, isUnitTestMode
|
|
||||||
) {
|
|
||||||
override fun apply(
|
override fun apply(
|
||||||
services: List<WizardService>,
|
services: List<WizardService>,
|
||||||
phases: Set<GenerationPhase>,
|
phases: Set<GenerationPhase>,
|
||||||
onTaskExecuting: (PipelineTask) -> Unit
|
onTaskExecuting: (PipelineTask) -> Unit
|
||||||
): TaskResult<Unit> = computeM {
|
): TaskResult<Unit> = computeM {
|
||||||
super.apply(services, setOf(GenerationPhase.PREPARE), onTaskExecuting)
|
val (settingsValuesFromYaml) = valuesReadingContext.parseYaml(yaml, pluginSettings)
|
||||||
val parsingData = with(valuesReadingContext) {
|
|
||||||
ParsingState(TemplatesPlugin::templates.propertyValue, emptyMap())
|
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)
|
super.apply(services, phases, onTaskExecuting)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val defaultPluginSettingValues
|
companion object {
|
||||||
get() = pluginSettings.mapNotNull { setting ->
|
val CLI_SERVICES_MANAGER = ServicesManager(Services.IDEA_INDEPENDENT_SERVICES) { services ->
|
||||||
val defaultValue = setting.defaultValue ?: return@mapNotNull null
|
services.firstOrNull { it is IdeaIndependentWizardService }
|
||||||
PluginSettingReference(setting) to defaultValue
|
}
|
||||||
}.toMap()
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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:
|
- type:
|
||||||
name: android
|
name: android
|
||||||
androidSdkPath: /home/user/Android/Sdk
|
androidSdkPath: /home/user/Android/Sdk
|
||||||
kind: singleplatformJvm
|
name: android
|
||||||
name: android
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'generatedProject'
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "generatedProject"
|
||||||
+1
-10
@@ -2,20 +2,11 @@ kotlin:
|
|||||||
projectKind: Multiplatform
|
projectKind: Multiplatform
|
||||||
modules:
|
modules:
|
||||||
- type: multiplatform
|
- type: multiplatform
|
||||||
kind: multiplatform
|
|
||||||
name: a
|
name: a
|
||||||
subModules:
|
subModules:
|
||||||
- type: jsNode
|
- type: jsNode
|
||||||
kind: target
|
|
||||||
name: nodeJs
|
name: nodeJs
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
- type:
|
- type:
|
||||||
name: jsBrowser
|
name: jsBrowser
|
||||||
testFramework: JS
|
testFramework: JS
|
||||||
kind: target
|
name: browser
|
||||||
name: browser
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'generatedProject'
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "generatedProject"
|
||||||
+1
-6
@@ -2,15 +2,10 @@ kotlin:
|
|||||||
projectKind: Multiplatform
|
projectKind: Multiplatform
|
||||||
modules:
|
modules:
|
||||||
- type: multiplatform
|
- type: multiplatform
|
||||||
kind: multiplatform
|
|
||||||
name: a
|
name: a
|
||||||
subModules:
|
subModules:
|
||||||
- type:
|
- type:
|
||||||
targetJvmVersion: "1.8"
|
targetJvmVersion: "1.8"
|
||||||
name: jvmTarget
|
name: jvmTarget
|
||||||
testFramework: JUNIT4
|
testFramework: JUNIT4
|
||||||
kind: target
|
name: jvm
|
||||||
name: jvm
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
+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"
|
targetJvmVersion: "1.6"
|
||||||
name: JVM Module
|
name: JVM Module
|
||||||
testFramework: JUNIT4
|
testFramework: JUNIT4
|
||||||
name: nya
|
name: nya
|
||||||
kind: singleplatformJvm
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'generatedProject'
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "generatedProject"
|
||||||
+1
-6
@@ -2,12 +2,7 @@ kotlin:
|
|||||||
projectKind: Multiplatform
|
projectKind: Multiplatform
|
||||||
modules:
|
modules:
|
||||||
- type: multiplatform
|
- type: multiplatform
|
||||||
kind: multiplatform
|
|
||||||
name: a
|
name: a
|
||||||
subModules:
|
subModules:
|
||||||
- type: nativeForCurrentSystem
|
- type: nativeForCurrentSystem
|
||||||
kind: target
|
name: myNative
|
||||||
name: myNative
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'generatedProject'
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "generatedProject"
|
||||||
+1
-10
@@ -2,23 +2,14 @@ kotlin:
|
|||||||
projectKind: Multiplatform
|
projectKind: Multiplatform
|
||||||
modules:
|
modules:
|
||||||
- type: multiplatform
|
- type: multiplatform
|
||||||
kind: multiplatform
|
|
||||||
name: a
|
name: a
|
||||||
subModules:
|
subModules:
|
||||||
- type:
|
- type:
|
||||||
targetJvmVersion: "9"
|
targetJvmVersion: "9"
|
||||||
name: jvmTarget
|
name: jvmTarget
|
||||||
testFramework: JUNIT4
|
testFramework: JUNIT4
|
||||||
kind: target
|
|
||||||
name: jvm
|
name: jvm
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
- type:
|
- type:
|
||||||
name: jsBrowser
|
name: jsBrowser
|
||||||
testFramework: JS
|
testFramework: JS
|
||||||
kind: target
|
name: a
|
||||||
name: a
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'generatedProject'
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "generatedProject"
|
||||||
+1
-6
@@ -2,12 +2,7 @@ kotlin:
|
|||||||
projectKind: Multiplatform
|
projectKind: Multiplatform
|
||||||
modules:
|
modules:
|
||||||
- type: multiplatform
|
- type: multiplatform
|
||||||
kind: multiplatform
|
|
||||||
name: a
|
name: a
|
||||||
subModules:
|
subModules:
|
||||||
- type: linuxX64Target
|
- type: linuxX64Target
|
||||||
kind: target
|
name: linuxX64
|
||||||
name: linuxX64
|
|
||||||
sourcesets:
|
|
||||||
- type: main
|
|
||||||
- type: test
|
|
||||||
+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
|
package org.jetbrains.kotlin.tools.projectWizard.cli
|
||||||
|
|
||||||
import com.intellij.testFramework.UsefulTestCase
|
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.div
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.onFailure
|
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.Services
|
import org.jetbrains.kotlin.tools.projectWizard.core.service.Services
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.Plugins
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard
|
||||||
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 java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
|
abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
|
||||||
|
abstract fun createWizard(directory: Path, buildSystem: BuildSystem, projectDirectory: Path): Wizard
|
||||||
|
|
||||||
fun doTest(directoryPath: String) {
|
fun doTest(directoryPath: String) {
|
||||||
val directory = Paths.get(directoryPath)
|
val directory = Paths.get(directoryPath)
|
||||||
val expectedDirectory = expectedDirectory(directory)
|
val expectedDirectory = expectedDirectory(directory)
|
||||||
@@ -33,67 +29,26 @@ abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun doTest(directory: Path, buildSystem: BuildSystem) {
|
private fun doTest(directory: Path, buildSystem: BuildSystem) {
|
||||||
val yaml = directory.resolve("settings.yaml").toFile().readText() + "\n" +
|
val tempDirectory = Files.createTempDirectory(null)
|
||||||
defaultStructure + "\n" +
|
val wizard = createWizard(directory, buildSystem, tempDirectory)
|
||||||
buildSystem.yaml
|
|
||||||
val tempDir = Files.createTempDirectory(null)
|
|
||||||
val wizard = YamlWizard(yaml, tempDir.toString(), Plugins.allPlugins, isUnitTestMode = true)
|
|
||||||
val result = wizard.apply(Services.IDEA_INDEPENDENT_SERVICES, GenerationPhase.ALL)
|
val result = wizard.apply(Services.IDEA_INDEPENDENT_SERVICES, GenerationPhase.ALL)
|
||||||
result.onFailure { errors ->
|
result.assertSuccess()
|
||||||
errors.forEach { error ->
|
|
||||||
if (error is ExceptionError) {
|
|
||||||
throw error.exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fail(errors.joinToString("\n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
val expectedDirectory = expectedDirectory(directory)
|
val expectedDirectory = expectedDirectory(directory)
|
||||||
|
|
||||||
compareFiles(
|
compareFiles(
|
||||||
expectedDirectory.allBuildFiles(buildSystem), expectedDirectory,
|
expectedDirectory.allBuildFiles(buildSystem), expectedDirectory,
|
||||||
tempDir.allBuildFiles(buildSystem), tempDir
|
tempDirectory.allBuildFiles(buildSystem), tempDirectory
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Path.allBuildFiles(buildSystem: BuildSystem) =
|
private fun Path.allBuildFiles(buildSystem: BuildSystem) =
|
||||||
listFiles { it.fileName.toString() == buildSystem.buildFileName }
|
listFiles { it.fileName.toString() in buildSystem.allBuildFileNames }
|
||||||
|
|
||||||
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()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun expectedDirectory(directory: Path): Path =
|
private fun expectedDirectory(directory: Path): Path =
|
||||||
(directory / EXPECTED_DIRECTORY_NAME).takeIf { Files.exists(it) } ?: directory
|
(directory / EXPECTED_DIRECTORY_NAME).takeIf { Files.exists(it) } ?: directory
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val EXPECTED_DIRECTORY_NAME = "expected"
|
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")
|
@TestMetadata("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class BuildFileGenerationTestGenerated extends AbstractBuildFileGenerationTest {
|
public class YamlBuildFileGenerationTestGenerated extends AbstractYamlBuildFileGenerationTest {
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||||
}
|
}
|
||||||
@@ -62,4 +62,9 @@ public class BuildFileGenerationTestGenerated extends AbstractBuildFileGeneratio
|
|||||||
public void testSimpleNativeTarget() throws Exception {
|
public void testSimpleNativeTarget() throws Exception {
|
||||||
runTest("libraries/tools/new-project-wizard/new-project-wizard-cli/testData/buildFileGeneration/simpleNativeTarget/");
|
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
|
package org.jetbrains.kotlin.tools.projectWizard.cli
|
||||||
|
|
||||||
|
import com.intellij.testFramework.UsefulTestCase
|
||||||
import org.hamcrest.core.Is
|
import org.hamcrest.core.Is
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
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 org.junit.Assert.assertThat
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@@ -34,4 +39,74 @@ internal fun compareFiles(
|
|||||||
for ((actualFile, expectedFile) in actualFilesSorted zip expectedFilesSorted) {
|
for ((actualFile, expectedFile) in actualFilesSorted zip expectedFilesSorted) {
|
||||||
KotlinTestUtils.assertEqualsToFile(expectedFile.toFile(), actualFile.readFile())
|
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"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -84,6 +84,6 @@ inline fun <reified E> SettingsOwner.enumSettingImpl(
|
|||||||
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
|
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
|
||||||
) where E : Enum<E>, E : DisplayableSettingItem = dropDownSetting<E>(title, neededAtPhase, enumParser()) {
|
) where E : Enum<E>, E : DisplayableSettingItem = dropDownSetting<E>(title, neededAtPhase, enumParser()) {
|
||||||
values = enumValues<E>().asList()
|
values = enumValues<E>().asList()
|
||||||
defaultValue = values.firstOrNull()
|
//
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
+3
-4
@@ -39,14 +39,13 @@ fun <T : Any> Parser<T>.parse(context: ParsingContext, value: Any?, path: String
|
|||||||
inline fun <reified E> enumParser(): Parser<E> where E : Enum<E>, E : DisplayableSettingItem = object : Parser<E>() {
|
inline fun <reified E> enumParser(): Parser<E> where E : Enum<E>, E : DisplayableSettingItem = object : Parser<E>() {
|
||||||
override fun ParsingContext.parse(value: Any?, path: String): TaskResult<E> = computeM {
|
override fun ParsingContext.parse(value: Any?, path: String): TaskResult<E> = computeM {
|
||||||
val (name) = value.parseAs<String>(path)
|
val (name) = value.parseAs<String>(path)
|
||||||
val createError = {
|
enumValues<E>().firstOrNull { enumValue ->
|
||||||
|
enumValue.name.equals(name, ignoreCase = true) || enumValue.text.equals(name, ignoreCase = true)
|
||||||
|
}.toResult {
|
||||||
ParseError(
|
ParseError(
|
||||||
"For setting `$path` one of [${enumValues<E>().joinToString { it.name }}] was expected but `$name` was found"
|
"For setting `$path` one of [${enumValues<E>().joinToString { it.name }}] was expected but `$name` was found"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val byEnumName = safe { enumValueOf<E>(name) }.mapFailure { createError() }
|
|
||||||
val byText = enumValues<E>().firstOrNull { it.text == name }.toResult { createError() }
|
|
||||||
byEnumName.recover { byText }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -57,13 +57,16 @@ open class ReadingContext(
|
|||||||
return serializer.fromString(savedValue)
|
return serializer.fromString(savedValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
val <V : Any> Setting<V, SettingType<V>>.savedOrDefaultValue: V?
|
val <V : Any> SettingReference<V, SettingType<V>>.savedOrDefaultValue: V?
|
||||||
get() = getSavedValueForSetting() ?: defaultValue
|
get() = setting.getSavedValueForSetting() ?: when (val defaultValue = setting.defaultValue) {
|
||||||
|
is SettingDefaultValue.Value -> defaultValue.value
|
||||||
|
is SettingDefaultValue.Dynamic<V> -> defaultValue.getter(this@ReadingContext, this)
|
||||||
|
null -> null
|
||||||
|
}
|
||||||
|
|
||||||
val <V : Any, T : SettingType<V>> SettingReference<V, T>.setting: Setting<V, T>
|
val <V : Any, T : SettingType<V>> SettingReference<V, T>.setting: Setting<V, T>
|
||||||
get() = with(this) { getSetting() }
|
get() = with(this) { getSetting() }
|
||||||
|
|
||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal val `access$context`: Context
|
internal val `access$context`: Context
|
||||||
get() = context
|
get() = context
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user