Wizard: do not allow creating compose projects with gradle groovy

#KT-42983 fixed
This commit is contained in:
Ilya Kirillov
2020-10-29 11:47:35 +03:00
parent 4f6fa1059c
commit 21928d8f51
4 changed files with 32 additions and 15 deletions
@@ -26,7 +26,7 @@ abstract class AbstractBuildFileGenerationTest : UsefulTestCase() {
val buildSystemsToRunFor = listOfNotNull(
BuildSystem.GRADLE_KOTLIN_DSL,
BuildSystem.GRADLE_GROOVY_DSL,
if (testParameters.runForGradleGroovy) BuildSystem.GRADLE_GROOVY_DSL else null,
if (testParameters.runForMaven) BuildSystem.MAVEN else null
)
@@ -40,6 +40,7 @@ project.kind.kotlin.js=Kotlin/JS
project.kind.multiplatform=Multiplatform
project.kind.singleplatform=JVM
project.kind.compose=JetBrains Compose (Experimental)
project.kind.compose.short.name=JetBrains Compose
project=Project
@@ -43,19 +43,17 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
}
validate { buildSystemType ->
if (!buildSystemType.isGradle
&& KotlinPlugin.projectKind.notRequiredSettingValue != ProjectKind.Singleplatform
) {
val projectKind = KotlinPlugin.projectKind.notRequiredSettingValue?.text?.capitalize()
?: KotlinNewProjectWizardBundle.message("project")
ValidationResult.ValidationError(
val projectKind = KotlinPlugin.projectKind.notRequiredSettingValue ?: ProjectKind.Multiplatform
when (buildSystemType) {
in projectKind.supportedBuildSystems -> ValidationResult.OK
else -> ValidationResult.ValidationError(
KotlinNewProjectWizardBundle.message(
"plugin.buildsystem.setting.type.error.wrong.project.kind",
projectKind,
projectKind.shortName.capitalize(),
buildSystemType.fullText
)
)
} else ValidationResult.OK
}
}
}
@@ -171,6 +169,10 @@ enum class BuildSystemType(
override val greyText: String?
get() = null
companion object {
val ALL_GRADLE = setOf(GradleKotlinDsl, GradleGroovyDsl)
}
}
val BuildSystemType.isGradle
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.inContextOfM
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemType
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.buildSystemType
import org.jetbrains.kotlin.tools.projectWizard.plugins.pomIR
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
@@ -194,12 +195,25 @@ class KotlinPlugin(context: Context) : Plugin(context) {
}
enum class ProjectKind(override val text: String, val message: String? = null) : DisplayableSettingItem {
Singleplatform(KotlinNewProjectWizardBundle.message("project.kind.singleplatform")),
Multiplatform(KotlinNewProjectWizardBundle.message("project.kind.multiplatform")),
Android(KotlinNewProjectWizardBundle.message("project.kind.android")),
Js(KotlinNewProjectWizardBundle.message("project.kind.kotlin.js")),
COMPOSE(KotlinNewProjectWizardBundle.message("project.kind.compose"), message = "uses Kotlin ${Versions.KOTLIN_VERSION_FOR_COMPOSE}")
enum class ProjectKind(
override val text: String,
val supportedBuildSystems: Set<BuildSystemType>,
val shortName: String = text,
val message: String? = null,
) : DisplayableSettingItem {
Singleplatform(
KotlinNewProjectWizardBundle.message("project.kind.singleplatform"),
supportedBuildSystems = BuildSystemType.values().toSet()
),
Multiplatform(KotlinNewProjectWizardBundle.message("project.kind.multiplatform"), supportedBuildSystems = BuildSystemType.ALL_GRADLE),
Android(KotlinNewProjectWizardBundle.message("project.kind.android"), supportedBuildSystems = BuildSystemType.ALL_GRADLE),
Js(KotlinNewProjectWizardBundle.message("project.kind.kotlin.js"), supportedBuildSystems = BuildSystemType.ALL_GRADLE),
COMPOSE(
KotlinNewProjectWizardBundle.message("project.kind.compose"),
supportedBuildSystems = setOf(BuildSystemType.GradleKotlinDsl),
shortName = KotlinNewProjectWizardBundle.message("project.kind.compose.short.name"),
message = "uses Kotlin ${Versions.KOTLIN_VERSION_FOR_COMPOSE}"
)
}
fun List<Module>.withAllSubModules(includeSourcesets: Boolean = false): List<Module> = buildList {