Wizard: allow "-" char in artifactId/groupId & fix their error messages
#KT-37820 fixed
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ plugin.android.setting.sdk=Android SDK
|
|||||||
|
|
||||||
validation.should.not.be.blank={0} should not be blank
|
validation.should.not.be.blank={0} should not be blank
|
||||||
validation.identifier={0} should consist only of letters, digits{1}
|
validation.identifier={0} should consist only of letters, digits{1}
|
||||||
validation.identifier.additional.symbols=", and symbols: {0}
|
validation.identifier.additional.symbols=, and symbols: {0}
|
||||||
validation.file.should.exists=File for {0} should exists
|
validation.file.should.exists=File for {0} should exists
|
||||||
|
|
||||||
version.error.bad.format=Bad version format for setting {0}
|
version.error.bad.format=Bad version format for setting {0}
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ object StringSettingType : SettingType<String>() {
|
|||||||
|
|
||||||
class Builder(
|
class Builder(
|
||||||
path: String,
|
path: String,
|
||||||
private val title: String,
|
val title: String,
|
||||||
neededAtPhase: GenerationPhase
|
neededAtPhase: GenerationPhase
|
||||||
) : SettingBuilder<String, StringSettingType>(path, title, neededAtPhase) {
|
) : SettingBuilder<String, StringSettingType>(path, title, neededAtPhase) {
|
||||||
fun shouldNotBeBlank() {
|
fun shouldNotBeBlank() {
|
||||||
|
|||||||
+9
-3
@@ -33,21 +33,21 @@ class StructurePlugin(context: Context) : Plugin(context) {
|
|||||||
) {
|
) {
|
||||||
isSavable = true
|
isSavable = true
|
||||||
shouldNotBeBlank()
|
shouldNotBeBlank()
|
||||||
validate(StringValidators.shouldBeValidIdentifier(title, setOf('.', '_')))
|
validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_GROUP_ID))
|
||||||
}
|
}
|
||||||
val artifactId by stringSetting(
|
val artifactId by stringSetting(
|
||||||
KotlinNewProjectWizardBundle.message("plugin.structure.setting.artifact.id"),
|
KotlinNewProjectWizardBundle.message("plugin.structure.setting.artifact.id"),
|
||||||
GenerationPhase.FIRST_STEP
|
GenerationPhase.FIRST_STEP
|
||||||
) {
|
) {
|
||||||
shouldNotBeBlank()
|
shouldNotBeBlank()
|
||||||
validate(StringValidators.shouldBeValidIdentifier(title, setOf('_')))
|
validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_ARTIFACT_ID))
|
||||||
}
|
}
|
||||||
val version by stringSetting(
|
val version by stringSetting(
|
||||||
KotlinNewProjectWizardBundle.message("plugin.structure.setting.version"),
|
KotlinNewProjectWizardBundle.message("plugin.structure.setting.version"),
|
||||||
GenerationPhase.FIRST_STEP
|
GenerationPhase.FIRST_STEP
|
||||||
) {
|
) {
|
||||||
shouldNotBeBlank()
|
shouldNotBeBlank()
|
||||||
validate(StringValidators.shouldBeValidIdentifier(title, setOf('_', '-', '.')))
|
validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_VERSION))
|
||||||
defaultValue = value("1.0-SNAPSHOT")
|
defaultValue = value("1.0-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,6 +56,12 @@ class StructurePlugin(context: Context) : Plugin(context) {
|
|||||||
service<FileSystemWizardService>().createDirectory(StructurePlugin::projectPath.reference.settingValue)
|
service<FileSystemWizardService>().createDirectory(StructurePlugin::projectPath.reference.settingValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val ALLOWED_SPECIAL_CHARS_IN_GROUP_ID = Module.ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES + '.'
|
||||||
|
private val ALLOWED_SPECIAL_CHARS_IN_ARTIFACT_ID = Module.ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES
|
||||||
|
private val ALLOWED_SPECIAL_CHARS_IN_VERSION = setOf('_', '-', '.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val Reader.projectPath
|
val Reader.projectPath
|
||||||
|
|||||||
Reference in New Issue
Block a user