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( val buildSystemsToRunFor = listOfNotNull(
BuildSystem.GRADLE_KOTLIN_DSL, BuildSystem.GRADLE_KOTLIN_DSL,
BuildSystem.GRADLE_GROOVY_DSL, if (testParameters.runForGradleGroovy) BuildSystem.GRADLE_GROOVY_DSL else null,
if (testParameters.runForMaven) BuildSystem.MAVEN 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.multiplatform=Multiplatform
project.kind.singleplatform=JVM project.kind.singleplatform=JVM
project.kind.compose=JetBrains Compose (Experimental) project.kind.compose=JetBrains Compose (Experimental)
project.kind.compose.short.name=JetBrains Compose
project=Project project=Project
@@ -43,19 +43,17 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
} }
validate { buildSystemType -> validate { buildSystemType ->
if (!buildSystemType.isGradle val projectKind = KotlinPlugin.projectKind.notRequiredSettingValue ?: ProjectKind.Multiplatform
&& KotlinPlugin.projectKind.notRequiredSettingValue != ProjectKind.Singleplatform when (buildSystemType) {
) { in projectKind.supportedBuildSystems -> ValidationResult.OK
val projectKind = KotlinPlugin.projectKind.notRequiredSettingValue?.text?.capitalize() else -> ValidationResult.ValidationError(
?: KotlinNewProjectWizardBundle.message("project")
ValidationResult.ValidationError(
KotlinNewProjectWizardBundle.message( KotlinNewProjectWizardBundle.message(
"plugin.buildsystem.setting.type.error.wrong.project.kind", "plugin.buildsystem.setting.type.error.wrong.project.kind",
projectKind, projectKind.shortName.capitalize(),
buildSystemType.fullText buildSystemType.fullText
) )
) )
} else ValidationResult.OK }
} }
} }
@@ -171,6 +169,10 @@ enum class BuildSystemType(
override val greyText: String? override val greyText: String?
get() = null get() = null
companion object {
val ALL_GRADLE = setOf(GradleKotlinDsl, GradleGroovyDsl)
}
} }
val BuildSystemType.isGradle 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.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.buildSystem.BuildSystemPlugin 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.buildSystem.buildSystemType
import org.jetbrains.kotlin.tools.projectWizard.plugins.pomIR import org.jetbrains.kotlin.tools.projectWizard.plugins.pomIR
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath 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 { enum class ProjectKind(
Singleplatform(KotlinNewProjectWizardBundle.message("project.kind.singleplatform")), override val text: String,
Multiplatform(KotlinNewProjectWizardBundle.message("project.kind.multiplatform")), val supportedBuildSystems: Set<BuildSystemType>,
Android(KotlinNewProjectWizardBundle.message("project.kind.android")), val shortName: String = text,
Js(KotlinNewProjectWizardBundle.message("project.kind.kotlin.js")), val message: String? = null,
COMPOSE(KotlinNewProjectWizardBundle.message("project.kind.compose"), message = "uses Kotlin ${Versions.KOTLIN_VERSION_FOR_COMPOSE}") ) : 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 { fun List<Module>.withAllSubModules(includeSourcesets: Boolean = false): List<Module> = buildList {