Wizard: specify path for plugin entities in one place

This commit is contained in:
Ilya Kirillov
2020-07-22 16:10:39 +03:00
committed by Kirill Shmakov
parent c05c72387e
commit 3c3ba361e8
22 changed files with 248 additions and 317 deletions
@@ -10,7 +10,6 @@ import kotlin.properties.ReadOnlyProperty
interface SettingsOwner { interface SettingsOwner {
fun <V : Any, T : SettingType<V>> settingDelegate( fun <V : Any, T : SettingType<V>> settingDelegate(
prefix: String,
create: (path: String) -> SettingBuilder<V, T> create: (path: String) -> SettingBuilder<V, T>
): ReadOnlyProperty<Any, Setting<V, T>> ): ReadOnlyProperty<Any, Setting<V, T>>
@@ -22,27 +21,24 @@ interface SettingsOwner {
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String = "",
init: DropDownSettingType.Builder<V>.() -> Unit = {} init: DropDownSettingType.Builder<V>.() -> Unit = {}
): ReadOnlyProperty<Any, Setting<V, DropDownSettingType<V>>> = settingDelegate(prefix) { path -> ): ReadOnlyProperty<Any, Setting<V, DropDownSettingType<V>>> = settingDelegate { path ->
DropDownSettingType.Builder(path, title, neededAtPhase, parser).apply(init) DropDownSettingType.Builder(path, title, neededAtPhase, parser).apply(init)
} }
fun stringSetting( fun stringSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
init: StringSettingType.Builder.() -> Unit = {} init: StringSettingType.Builder.() -> Unit = {}
) = settingDelegate(prefix) { path -> ) = settingDelegate { path ->
StringSettingType.Builder(path, title, neededAtPhase).apply(init) StringSettingType.Builder(path, title, neededAtPhase).apply(init)
} }
fun booleanSetting( fun booleanSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
init: BooleanSettingType.Builder.() -> Unit = {} init: BooleanSettingType.Builder.() -> Unit = {}
) = settingDelegate(prefix) { path -> ) = settingDelegate { path ->
BooleanSettingType.Builder(path, title, neededAtPhase).apply(init) BooleanSettingType.Builder(path, title, neededAtPhase).apply(init)
} }
@@ -50,18 +46,16 @@ interface SettingsOwner {
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String = "",
init: ValueSettingType.Builder<V>.() -> Unit = {} init: ValueSettingType.Builder<V>.() -> Unit = {}
) = settingDelegate(prefix) { path -> ) = settingDelegate { path ->
ValueSettingType.Builder(path, title, neededAtPhase, parser).apply(init) ValueSettingType.Builder(path, title, neededAtPhase, parser).apply(init)
} }
fun versionSetting( fun versionSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
init: VersionSettingType.Builder.() -> Unit = {} init: VersionSettingType.Builder.() -> Unit = {}
) = settingDelegate(prefix) { path -> ) = settingDelegate { path ->
VersionSettingType.Builder(path, title, neededAtPhase).apply(init) VersionSettingType.Builder(path, title, neededAtPhase).apply(init)
} }
@@ -69,18 +63,16 @@ interface SettingsOwner {
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String = "",
init: ListSettingType.Builder<V>.() -> Unit = {} init: ListSettingType.Builder<V>.() -> Unit = {}
) = settingDelegate(prefix) { path -> ) = settingDelegate { path ->
ListSettingType.Builder(path, title, neededAtPhase, parser).apply(init) ListSettingType.Builder(path, title, neededAtPhase, parser).apply(init)
} }
fun pathSetting( fun pathSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
init: PathSettingType.Builder.() -> Unit = {} init: PathSettingType.Builder.() -> Unit = {}
) = settingDelegate(prefix) { path -> ) = settingDelegate { path ->
PathSettingType.Builder(path, title, neededAtPhase).apply(init) PathSettingType.Builder(path, title, neededAtPhase).apply(init)
} }
} }
@@ -89,10 +81,8 @@ interface SettingsOwner {
inline fun <reified E> SettingsOwner.enumSettingImpl( inline fun <reified E> SettingsOwner.enumSettingImpl(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {} crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
) where E : Enum<E>, E : DisplayableSettingItem = dropDownSetting<E>(title, neededAtPhase, enumParser(), prefix) { ) where E : Enum<E>, E : DisplayableSettingItem = dropDownSetting<E>(title, neededAtPhase, enumParser()) {
values = enumValues<E>().asList() values = enumValues<E>().asList()
//
init() init()
} }
@@ -26,146 +26,130 @@ abstract class Plugin(override val context: Context) : EntityBase(),
abstract val properties: List<Property<*>> abstract val properties: List<Property<*>>
abstract val settings: List<PluginSetting<*, *>> abstract val settings: List<PluginSetting<*, *>>
abstract val pipelineTasks: List<PipelineTask> abstract val pipelineTasks: List<PipelineTask>
}
companion object : SettingsOwner {
fun pipelineTask( abstract class PluginSettingsOwner : SettingsOwner {
prefix: String, abstract val pluginPath: String
phase: GenerationPhase,
init: PipelineTask.Builder.() -> Unit fun pipelineTask(
): ReadOnlyProperty<Any, PipelineTask> = phase: GenerationPhase,
cached { name -> PipelineTask.Builder(withPrefix(prefix, name), phase).apply(init).build() } init: PipelineTask.Builder.() -> Unit
): ReadOnlyProperty<Any, PipelineTask> =
fun <A, B : Any> task1( cached { name -> PipelineTask.Builder(withPluginPath(name), phase).apply(init).build() }
prefix: String,
init: Task1.Builder<A, B>.() -> Unit fun <A, B : Any> task1(
): ReadOnlyProperty<Any, Task1<A, B>> = cached { name -> Task1.Builder<A, B>(withPrefix(prefix, name)).apply(init).build() } init: Task1.Builder<A, B>.() -> Unit
): ReadOnlyProperty<Any, Task1<A, B>> = cached { name -> Task1.Builder<A, B>(withPluginPath(name)).apply(init).build() }
fun <T : Any> property(
prefix: String, fun <T : Any> property(
defaultValue: T, defaultValue: T,
init: Property.Builder<T>.() -> Unit = {} init: Property.Builder<T>.() -> Unit = {}
): ReadOnlyProperty<Any, Property<T>> = ): ReadOnlyProperty<Any, Property<T>> =
cached { name -> Property.Builder(withPrefix(prefix, name), defaultValue).apply(init).build() } cached { name -> Property.Builder(withPluginPath(name), defaultValue).apply(init).build() }
fun <T : Any> listProperty(prefix: String, vararg defaultValues: T, init: Property.Builder<List<T>>.() -> Unit = {}) = fun <T : Any> listProperty(vararg defaultValues: T, init: Property.Builder<List<T>>.() -> Unit = {}) =
property(prefix, defaultValues.toList(), init) property(defaultValues.toList(), init)
private fun withPrefix(name: String, prefix: String): String = if (prefix.isNotEmpty()) "$prefix.$name" else name private fun withPluginPath(name: String): String = "$pluginPath.$name"
override fun <V : Any, T : SettingType<V>> settingDelegate( override fun <V : Any, T : SettingType<V>> settingDelegate(
prefix: String, create: (path: String) -> SettingBuilder<V, T>
create: (path: String) -> SettingBuilder<V, T> ): ReadOnlyProperty<Any, PluginSetting<V, T>> = cached { name -> PluginSetting(create(withPluginPath(name)).buildInternal()) }
): ReadOnlyProperty<Any, PluginSetting<V, T>> = cached { name -> PluginSetting(create(withPrefix(name, prefix)).buildInternal()) }
// setting types
// setting types
@Suppress("UNCHECKED_CAST")
@Suppress("UNCHECKED_CAST") override fun <V : DisplayableSettingItem> dropDownSetting(
override fun <V : DisplayableSettingItem> dropDownSetting( title: String,
title: String, neededAtPhase: GenerationPhase,
neededAtPhase: GenerationPhase, parser: Parser<V>,
parser: Parser<V>, init: DropDownSettingType.Builder<V>.() -> Unit
prefix: String, ): ReadOnlyProperty<Any, PluginSetting<V, DropDownSettingType<V>>> =
init: DropDownSettingType.Builder<V>.() -> Unit super.dropDownSetting(
): ReadOnlyProperty<Any, PluginSetting<V, DropDownSettingType<V>>> = title,
super.dropDownSetting( neededAtPhase,
title, parser,
neededAtPhase, init
parser, ) as ReadOnlyProperty<Any, PluginSetting<V, DropDownSettingType<V>>>
prefix,
init @Suppress("UNCHECKED_CAST")
) as ReadOnlyProperty<Any, PluginSetting<V, DropDownSettingType<V>>> override fun stringSetting(
title: String,
@Suppress("UNCHECKED_CAST") neededAtPhase: GenerationPhase,
override fun stringSetting( init: StringSettingType.Builder.() -> Unit
title: String, ): ReadOnlyProperty<Any, PluginSetting<String, StringSettingType>> =
neededAtPhase: GenerationPhase, super.stringSetting(
prefix: String, title,
init: StringSettingType.Builder.() -> Unit neededAtPhase,
): ReadOnlyProperty<Any, PluginSetting<String, StringSettingType>> = init
super.stringSetting( ) as ReadOnlyProperty<Any, PluginSetting<String, StringSettingType>>
title,
neededAtPhase, @Suppress("UNCHECKED_CAST")
prefix, override fun booleanSetting(
init title: String,
) as ReadOnlyProperty<Any, PluginSetting<String, StringSettingType>> neededAtPhase: GenerationPhase,
init: BooleanSettingType.Builder.() -> Unit
@Suppress("UNCHECKED_CAST") ): ReadOnlyProperty<Any, PluginSetting<Boolean, BooleanSettingType>> =
override fun booleanSetting( super.booleanSetting(
title: String, title,
neededAtPhase: GenerationPhase, neededAtPhase,
prefix: String, init
init: BooleanSettingType.Builder.() -> Unit ) as ReadOnlyProperty<Any, PluginSetting<Boolean, BooleanSettingType>>
): ReadOnlyProperty<Any, PluginSetting<Boolean, BooleanSettingType>> =
super.booleanSetting( @Suppress("UNCHECKED_CAST")
title, override fun <V : Any> valueSetting(
neededAtPhase, title: String,
prefix, neededAtPhase: GenerationPhase,
init parser: Parser<V>,
) as ReadOnlyProperty<Any, PluginSetting<Boolean, BooleanSettingType>> init: ValueSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, PluginSetting<V, ValueSettingType<V>>> =
@Suppress("UNCHECKED_CAST") super.valueSetting(
override fun <V : Any> valueSetting( title,
title: String, neededAtPhase,
neededAtPhase: GenerationPhase, parser,
parser: Parser<V>, init
prefix: String, ) as ReadOnlyProperty<Any, PluginSetting<V, ValueSettingType<V>>>
init: ValueSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, PluginSetting<V, ValueSettingType<V>>> = @Suppress("UNCHECKED_CAST")
super.valueSetting( override fun versionSetting(
title, title: String,
neededAtPhase, neededAtPhase: GenerationPhase,
parser, init: VersionSettingType.Builder.() -> Unit
prefix, ): ReadOnlyProperty<Any, PluginSetting<Version, VersionSettingType>> =
init super.versionSetting(
) as ReadOnlyProperty<Any, PluginSetting<V, ValueSettingType<V>>> title,
neededAtPhase,
@Suppress("UNCHECKED_CAST") init
override fun versionSetting( ) as ReadOnlyProperty<Any, PluginSetting<Version, VersionSettingType>>
title: String,
neededAtPhase: GenerationPhase, @Suppress("UNCHECKED_CAST")
prefix: String, override fun <V : Any> listSetting(
init: VersionSettingType.Builder.() -> Unit title: String,
): ReadOnlyProperty<Any, PluginSetting<Version, VersionSettingType>> = neededAtPhase: GenerationPhase,
super.versionSetting( parser: Parser<V>,
title, init: ListSettingType.Builder<V>.() -> Unit
neededAtPhase, ): ReadOnlyProperty<Any, PluginSetting<List<V>, ListSettingType<V>>> =
prefix, super.listSetting(
init title,
) as ReadOnlyProperty<Any, PluginSetting<Version, VersionSettingType>> neededAtPhase,
parser,
@Suppress("UNCHECKED_CAST") init
override fun <V : Any> listSetting( ) as ReadOnlyProperty<Any, PluginSetting<List<V>, ListSettingType<V>>>
title: String,
neededAtPhase: GenerationPhase, @Suppress("UNCHECKED_CAST")
parser: Parser<V>, override fun pathSetting(
prefix: String, title: String,
init: ListSettingType.Builder<V>.() -> Unit neededAtPhase: GenerationPhase,
): ReadOnlyProperty<Any, PluginSetting<List<V>, ListSettingType<V>>> = init: PathSettingType.Builder.() -> Unit
super.listSetting( ): ReadOnlyProperty<Any, PluginSetting<Path, PathSettingType>> =
title, super.pathSetting(title, neededAtPhase, init) as ReadOnlyProperty<Any, PluginSetting<Path, PathSettingType>>
neededAtPhase,
parser, @Suppress("UNCHECKED_CAST")
prefix, inline fun <reified E> enumSetting(
init title: String,
) as ReadOnlyProperty<Any, PluginSetting<List<V>, ListSettingType<V>>> neededAtPhase: GenerationPhase,
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
@Suppress("UNCHECKED_CAST") ): ReadOnlyProperty<Any, PluginSetting<E, DropDownSettingType<E>>> where E : Enum<E>, E : DisplayableSettingItem =
override fun pathSetting( enumSettingImpl(title, neededAtPhase, init) as ReadOnlyProperty<Any, PluginSetting<E, DropDownSettingType<E>>>
title: String,
neededAtPhase: GenerationPhase,
prefix: String,
init: PathSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, PluginSetting<Path, PathSettingType>> =
super.pathSetting(title, neededAtPhase, prefix, init) as ReadOnlyProperty<Any, PluginSetting<Path, PathSettingType>>
@Suppress("UNCHECKED_CAST")
inline fun <reified E> enumSetting(
title: String,
neededAtPhase: GenerationPhase,
prefix: String,
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
): ReadOnlyProperty<Any, PluginSetting<E, DropDownSettingType<E>>> where E : Enum<E>, E : DisplayableSettingItem =
enumSettingImpl(title, neededAtPhase, prefix, init) as ReadOnlyProperty<Any, PluginSetting<E, DropDownSettingType<E>>>
}
} }
@@ -62,7 +62,6 @@ fun <V : Any, T : SettingType<V>> Reader.settingValue(module: Module, setting: M
abstract class ModuleConfiguratorSettings : SettingsOwner { abstract class ModuleConfiguratorSettings : SettingsOwner {
final override fun <V : Any, T : SettingType<V>> settingDelegate( final override fun <V : Any, T : SettingType<V>> settingDelegate(
prefix: String,
create: (path: String) -> SettingBuilder<V, T> create: (path: String) -> SettingBuilder<V, T>
): ReadOnlyProperty<Any?, ModuleConfiguratorSetting<V, T>> = cached { name -> ): ReadOnlyProperty<Any?, ModuleConfiguratorSetting<V, T>> = cached { name ->
ModuleConfiguratorSetting(create(name).buildInternal()) ModuleConfiguratorSetting(create(name).buildInternal())
@@ -73,14 +72,12 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String,
init: DropDownSettingType.Builder<V>.() -> Unit init: DropDownSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, DropDownSettingType<V>>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, DropDownSettingType<V>>> =
super.dropDownSetting( super.dropDownSetting(
title, title,
neededAtPhase, neededAtPhase,
parser, parser,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, DropDownSettingType<V>>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, DropDownSettingType<V>>>
@@ -88,13 +85,11 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
final override fun stringSetting( final override fun stringSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: StringSettingType.Builder.() -> Unit init: StringSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<String, StringSettingType>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<String, StringSettingType>> =
super.stringSetting( super.stringSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<String, StringSettingType>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<String, StringSettingType>>
@@ -102,13 +97,11 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
final override fun booleanSetting( final override fun booleanSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: BooleanSettingType.Builder.() -> Unit init: BooleanSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<Boolean, BooleanSettingType>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<Boolean, BooleanSettingType>> =
super.booleanSetting( super.booleanSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<Boolean, BooleanSettingType>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<Boolean, BooleanSettingType>>
@@ -117,14 +110,12 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String,
init: ValueSettingType.Builder<V>.() -> Unit init: ValueSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, ValueSettingType<V>>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, ValueSettingType<V>>> =
super.valueSetting( super.valueSetting(
title, title,
neededAtPhase, neededAtPhase,
parser, parser,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, ValueSettingType<V>>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<V, ValueSettingType<V>>>
@@ -132,13 +123,11 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
final override fun versionSetting( final override fun versionSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: VersionSettingType.Builder.() -> Unit init: VersionSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<Version, VersionSettingType>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<Version, VersionSettingType>> =
super.versionSetting( super.versionSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<Version, VersionSettingType>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<Version, VersionSettingType>>
@@ -147,14 +136,12 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String,
init: ListSettingType.Builder<V>.() -> Unit init: ListSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<List<V>, ListSettingType<V>>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<List<V>, ListSettingType<V>>> =
super.listSetting( super.listSetting(
title, title,
neededAtPhase, neededAtPhase,
parser, parser,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<List<V>, ListSettingType<V>>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<List<V>, ListSettingType<V>>>
@@ -162,13 +149,11 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
final override fun pathSetting( final override fun pathSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: PathSettingType.Builder.() -> Unit init: PathSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<Path, PathSettingType>> = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<Path, PathSettingType>> =
super.pathSetting( super.pathSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<Path, PathSettingType>> ) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<Path, PathSettingType>>
@@ -176,10 +161,9 @@ abstract class ModuleConfiguratorSettings : SettingsOwner {
inline fun <reified E> enumSetting( inline fun <reified E> enumSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {} crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
): ReadOnlyProperty<Any, ModuleConfiguratorSetting<E, DropDownSettingType<E>>> where E : Enum<E>, E : DisplayableSettingItem = ): ReadOnlyProperty<Any, ModuleConfiguratorSetting<E, DropDownSettingType<E>>> where E : Enum<E>, E : DisplayableSettingItem =
enumSettingImpl(title, neededAtPhase, prefix, init) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<E, DropDownSettingType<E>>> enumSettingImpl(title, neededAtPhase, init) as ReadOnlyProperty<Any, ModuleConfiguratorSetting<E, DropDownSettingType<E>>>
} }
interface ModuleConfiguratorWithSettings : ModuleConfigurator { interface ModuleConfiguratorWithSettings : ModuleConfigurator {
@@ -6,10 +6,7 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins package org.jetbrains.kotlin.tools.projectWizard.plugins
import org.jetbrains.kotlin.tools.projectWizard.KotlinNewProjectWizardBundle import org.jetbrains.kotlin.tools.projectWizard.KotlinNewProjectWizardBundle
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.*
import org.jetbrains.kotlin.tools.projectWizard.core.Plugin
import org.jetbrains.kotlin.tools.projectWizard.core.UNIT_SUCCESS
import org.jetbrains.kotlin.tools.projectWizard.core.checker
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.Property import org.jetbrains.kotlin.tools.projectWizard.core.entity.Property
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
@@ -22,7 +19,7 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.withAllSubModules import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.withAllSubModules
class AndroidPlugin(context: Context) : Plugin(context) { class AndroidPlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
override val settings: List<PluginSetting<*, *>> = listOf( override val settings: List<PluginSetting<*, *>> = listOf(
androidSdkPath androidSdkPath
@@ -32,13 +29,12 @@ class AndroidPlugin(context: Context) : Plugin(context) {
) )
override val properties: List<Property<*>> = listOf() override val properties: List<Property<*>> = listOf()
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "android" override val pluginPath: String = "android"
val androidSdkPath by pathSetting( val androidSdkPath by pathSetting(
KotlinNewProjectWizardBundle.message("plugin.android.setting.sdk"), KotlinNewProjectWizardBundle.message("plugin.android.setting.sdk"),
neededAtPhase = GenerationPhase.PROJECT_GENERATION, neededAtPhase = GenerationPhase.PROJECT_GENERATION,
PATH
) { ) {
isSavable = true isSavable = true
isAvailable = isAndroidContainingProject isAvailable = isAndroidContainingProject
@@ -51,7 +47,7 @@ class AndroidPlugin(context: Context) : Plugin(context) {
.any { it.configurator is AndroidModuleConfigurator } .any { it.configurator is AndroidModuleConfigurator }
} }
val addAndroidSdkToLocalProperties by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val addAndroidSdkToLocalProperties by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(GradlePlugin.createLocalPropertiesFile) runBefore(GradlePlugin.createLocalPropertiesFile)
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
isAvailable = isAndroidContainingProject isAvailable = isAndroidContainingProject
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.tools.projectWizard.plugins
import org.jetbrains.kotlin.tools.projectWizard.WizardRunConfiguration import org.jetbrains.kotlin.tools.projectWizard.WizardRunConfiguration
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.Plugin import org.jetbrains.kotlin.tools.projectWizard.core.Plugin
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.UNIT_SUCCESS import org.jetbrains.kotlin.tools.projectWizard.core.UNIT_SUCCESS
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.Property import org.jetbrains.kotlin.tools.projectWizard.core.entity.Property
@@ -17,18 +18,18 @@ import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin
class RunConfigurationsPlugin(context: Context) : Plugin(context) { class RunConfigurationsPlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
override val settings: List<PluginSetting<*, *>> = emptyList() override val settings: List<PluginSetting<*, *>> = emptyList()
override val pipelineTasks: List<PipelineTask> = listOf(createRunConfigurationsTask) override val pipelineTasks: List<PipelineTask> = listOf(createRunConfigurationsTask)
override val properties: List<Property<*>> = listOf(configurations) override val properties: List<Property<*>> = listOf(configurations)
companion object { companion object: PluginSettingsOwner() {
private const val PATH = "runConfigurations" override val pluginPath = "runConfigurations"
val configurations by listProperty<WizardRunConfiguration>(PATH) val configurations by listProperty<WizardRunConfiguration>()
val createRunConfigurationsTask by pipelineTask(PATH, GenerationPhase.PROJECT_IMPORT) { val createRunConfigurationsTask by pipelineTask( GenerationPhase.PROJECT_IMPORT) {
runBefore(BuildSystemPlugin.importProject) runBefore(BuildSystemPlugin.importProject)
withAction { withAction {
@@ -8,7 +8,6 @@ import org.jetbrains.kotlin.tools.projectWizard.core.entity.Property
import org.jetbrains.kotlin.tools.projectWizard.core.entity.StringValidators import org.jetbrains.kotlin.tools.projectWizard.core.entity.StringValidators
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.reference
import org.jetbrains.kotlin.tools.projectWizard.core.service.FileSystemWizardService import org.jetbrains.kotlin.tools.projectWizard.core.service.FileSystemWizardService
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.PomIR import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.PomIR
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
@@ -18,10 +17,10 @@ import java.nio.file.Files
import java.nio.file.Paths import java.nio.file.Paths
class StructurePlugin(context: Context) : Plugin(context) { class StructurePlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "structure" override val pluginPath = "structure"
private val ALLOWED_SPECIAL_CHARS_IN_GROUP_ID = Module.ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES + '.' 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_ARTIFACT_ID = Module.ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES
@@ -30,7 +29,6 @@ class StructurePlugin(context: Context) : Plugin(context) {
val projectPath by pathSetting( val projectPath by pathSetting(
KotlinNewProjectWizardBundle.message("plugin.structure.setting.location"), KotlinNewProjectWizardBundle.message("plugin.structure.setting.location"),
GenerationPhase.FIRST_STEP, GenerationPhase.FIRST_STEP,
PATH
) { ) {
defaultValue = value(Paths.get(".")) defaultValue = value(Paths.get("."))
@@ -46,7 +44,6 @@ class StructurePlugin(context: Context) : Plugin(context) {
val name by stringSetting( val name by stringSetting(
KotlinNewProjectWizardBundle.message("plugin.structure.setting.name"), KotlinNewProjectWizardBundle.message("plugin.structure.setting.name"),
GenerationPhase.FIRST_STEP, GenerationPhase.FIRST_STEP,
PATH
) { ) {
shouldNotBeBlank() shouldNotBeBlank()
validate(StringValidators.shouldBeValidIdentifier(title, Module.ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES)) validate(StringValidators.shouldBeValidIdentifier(title, Module.ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES))
@@ -55,7 +52,6 @@ class StructurePlugin(context: Context) : Plugin(context) {
val groupId by stringSetting( val groupId by stringSetting(
KotlinNewProjectWizardBundle.message("plugin.structure.setting.group.id"), KotlinNewProjectWizardBundle.message("plugin.structure.setting.group.id"),
GenerationPhase.FIRST_STEP, GenerationPhase.FIRST_STEP,
PATH
) { ) {
isSavable = true isSavable = true
shouldNotBeBlank() shouldNotBeBlank()
@@ -64,7 +60,6 @@ class StructurePlugin(context: Context) : Plugin(context) {
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,
PATH
) { ) {
shouldNotBeBlank() shouldNotBeBlank()
validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_ARTIFACT_ID)) validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_ARTIFACT_ID))
@@ -72,13 +67,12 @@ class StructurePlugin(context: Context) : Plugin(context) {
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,
PATH
) { ) {
shouldNotBeBlank() shouldNotBeBlank()
validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_VERSION)) validate(StringValidators.shouldBeValidIdentifier(title, ALLOWED_SPECIAL_CHARS_IN_VERSION))
defaultValue = value("1.0-SNAPSHOT") defaultValue = value("1.0-SNAPSHOT")
} }
val createProjectDir by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createProjectDir by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
withAction { withAction {
service<FileSystemWizardService>().createDirectory(StructurePlugin.projectPath.settingValue) service<FileSystemWizardService>().createDirectory(StructurePlugin.projectPath.settingValue)
} }
@@ -27,15 +27,14 @@ import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repository
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles
abstract class BuildSystemPlugin(context: Context) : Plugin(context) { abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "buildSystem" override val pluginPath = "buildSystem"
val type by enumSetting<BuildSystemType>( val type by enumSetting<BuildSystemType>(
KotlinNewProjectWizardBundle.message("plugin.buildsystem.setting.type"), KotlinNewProjectWizardBundle.message("plugin.buildsystem.setting.type"),
GenerationPhase.FIRST_STEP, GenerationPhase.FIRST_STEP,
PATH
) { ) {
isSavable = true isSavable = true
filter = { _, type -> filter = { _, type ->
@@ -60,13 +59,13 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
} }
} }
val buildSystemData by property<List<BuildSystemData>>(PATH, emptyList()) val buildSystemData by property<List<BuildSystemData>>(emptyList())
val buildFiles by listProperty<BuildFileIR>(PATH) val buildFiles by listProperty<BuildFileIR>()
val pluginRepositoreis by listProperty<Repository>(PATH) val pluginRepositoreis by listProperty<Repository>()
val takeRepositoriesFromDependencies by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val takeRepositoriesFromDependencies by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(createModules) runBefore(createModules)
runAfter(TemplatesPlugin.postApplyTemplatesToModules) runAfter(TemplatesPlugin.postApplyTemplatesToModules)
@@ -88,7 +87,7 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
} }
} }
val createModules by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createModules by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(StructurePlugin.createProjectDir) runAfter(StructurePlugin.createProjectDir)
withAction { withAction {
val fileSystem = service<FileSystemWizardService>() val fileSystem = service<FileSystemWizardService>()
@@ -103,7 +102,7 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
} }
} }
val importProject by pipelineTask(PATH, GenerationPhase.PROJECT_IMPORT) { val importProject by pipelineTask(GenerationPhase.PROJECT_IMPORT) {
runAfter(createModules) runAfter(createModules)
withAction { withAction {
val data = buildSystemData.propertyValue.first { it.type == buildSystemType } val data = buildSystemData.propertyValue.first { it.type == buildSystemType }
@@ -111,13 +110,6 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
.importProject(this, StructurePlugin.projectPath.settingValue, allIRModules, buildSystemType) .importProject(this, StructurePlugin.projectPath.settingValue, allIRModules, buildSystemType)
} }
} }
fun addBuildSystemData(prefix: String, data: BuildSystemData) = pipelineTask(prefix, GenerationPhase.PREPARE) {
runBefore(createModules)
withAction {
buildSystemData.addValues(data)
}
}
} }
override val settings: List<PluginSetting<*, *>> = listOf( override val settings: List<PluginSetting<*, *>> = listOf(
@@ -135,6 +127,13 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
) )
} }
fun PluginSettingsOwner.addBuildSystemData(data: BuildSystemData) = pipelineTask(GenerationPhase.PREPARE) {
runBefore(BuildSystemPlugin.createModules)
withAction {
BuildSystemPlugin.buildSystemData.addValues(data)
}
}
data class BuildSystemData( data class BuildSystemData(
val type: BuildSystemType, val type: BuildSystemType,
val buildFileData: BuildFileData? val buildFileData: BuildFileData?
@@ -1,15 +1,15 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
class JpsPlugin(context: Context) : BuildSystemPlugin(context) { class JpsPlugin(context: Context) : BuildSystemPlugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "buildSystem.jps" override val pluginPath = "buildSystem.jps"
val addBuildSystemData by addBuildSystemData( val addBuildSystemData by addBuildSystemData(
PATH,
BuildSystemData( BuildSystemData(
type = BuildSystemType.Jps, type = BuildSystemType.Jps,
buildFileData = null buildFileData = null
@@ -1,6 +1,7 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.asSuccess import org.jetbrains.kotlin.tools.projectWizard.core.asSuccess
import org.jetbrains.kotlin.tools.projectWizard.core.checker import org.jetbrains.kotlin.tools.projectWizard.core.checker
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
@@ -14,16 +15,16 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.MavenPrinter
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.updateBuildFiles
class MavenPlugin(context: Context) : BuildSystemPlugin(context) { class MavenPlugin(context: Context) : BuildSystemPlugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "buildSystem.maven" override val pluginPath = "buildSystem.maven"
private val isMaven = checker { private val isMaven = checker {
type.settingValue == BuildSystemType.Maven type.settingValue == BuildSystemType.Maven
} }
val createSettingsFileTask by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createSettingsFileTask by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
runBefore(createModules) runBefore(createModules)
isAvailable = isMaven isAvailable = isMaven
@@ -45,7 +46,7 @@ class MavenPlugin(context: Context) : BuildSystemPlugin(context) {
} }
} }
val addBuildSystemPluginRepositories by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val addBuildSystemPluginRepositories by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createPluginRepositories) runAfter(KotlinPlugin.createPluginRepositories)
runBefore(createModules) runBefore(createModules)
isAvailable = isMaven isAvailable = isMaven
@@ -59,7 +60,6 @@ class MavenPlugin(context: Context) : BuildSystemPlugin(context) {
} }
val addBuildSystemData by addBuildSystemData( val addBuildSystemData by addBuildSystemData(
PATH,
BuildSystemData( BuildSystemData(
type = BuildSystemType.Maven, type = BuildSystemType.Maven,
buildFileData = BuildFileData( buildFileData = BuildFileData(
@@ -21,25 +21,24 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.printBuildFile
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath import org.jetbrains.kotlin.tools.projectWizard.plugins.projectPath
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.DefaultRepository
import org.jetbrains.kotlin.tools.projectWizard.settings.version.Version
import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplate
import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplateDescriptor import org.jetbrains.kotlin.tools.projectWizard.templates.FileTemplateDescriptor
abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) { abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "buildSystem.gradle" override val pluginPath = "buildSystem.gradle"
val gradleProperties by listProperty( val gradleProperties by listProperty(
PATH,
"kotlin.code.style" to "official" "kotlin.code.style" to "official"
) )
val settingsGradleFileIRs by listProperty<BuildSystemIR>(PATH) val settingsGradleFileIRs by listProperty<BuildSystemIR>()
val createGradlePropertiesFile by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createGradlePropertiesFile by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
runBefore(TemplatesPlugin.renderFileTemplates) runBefore(TemplatesPlugin.renderFileTemplates)
isAvailable = isGradle isAvailable = isGradle
@@ -61,9 +60,9 @@ abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
} }
} }
val localProperties by listProperty<Pair<String, String>>(PATH) val localProperties by listProperty<Pair<String, String>>()
val createLocalPropertiesFile by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createLocalPropertiesFile by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
runBefore(TemplatesPlugin.renderFileTemplates) runBefore(TemplatesPlugin.renderFileTemplates)
isAvailable = isGradle isAvailable = isGradle
@@ -85,7 +84,7 @@ abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
private val isGradle = checker { buildSystemType.isGradle } private val isGradle = checker { buildSystemType.isGradle }
val initGradleWrapperTask by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val initGradleWrapperTask by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(TemplatesPlugin.renderFileTemplates) runBefore(TemplatesPlugin.renderFileTemplates)
isAvailable = isGradle isAvailable = isGradle
withAction { withAction {
@@ -105,7 +104,7 @@ abstract class GradlePlugin(context: Context) : BuildSystemPlugin(context) {
} }
val createSettingsFileTask by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createSettingsFileTask by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
runAfter(KotlinPlugin.createPluginRepositories) runAfter(KotlinPlugin.createPluginRepositories)
isAvailable = isGradle isAvailable = isGradle
@@ -1,20 +1,21 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildFileData import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildFileData
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemData import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemData
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.addBuildSystemData
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.printer.GradlePrinter import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.GradlePrinter
class GroovyDslPlugin(context: Context) : GradlePlugin(context) { class GroovyDslPlugin(context: Context) : GradlePlugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "buildSystem.gradle.groovyDsl" override val pluginPath = "buildSystem.gradle.groovyDsl"
val addBuildSystemData by addBuildSystemData( val addBuildSystemData by addBuildSystemData(
PATH,
BuildSystemData( BuildSystemData(
type = BuildSystemType.GradleGroovyDsl, type = BuildSystemType.GradleGroovyDsl,
buildFileData = BuildFileData( buildFileData = BuildFileData(
@@ -1,20 +1,21 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.gradle
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildFileData import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildFileData
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemData import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemData
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.addBuildSystemData
import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.GradlePrinter import org.jetbrains.kotlin.tools.projectWizard.plugins.printer.GradlePrinter
class KotlinDslPlugin(context: Context) : GradlePlugin(context) { class KotlinDslPlugin(context: Context) : GradlePlugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "buildSystem.gradle.kotlinDsl" override val pluginPath = "buildSystem.gradle.kotlinDsl"
val addBuildSystemData by addBuildSystemData( val addBuildSystemData by addBuildSystemData(
PATH,
BuildSystemData( BuildSystemData(
type = BuildSystemType.GradleKotlinDsl, type = BuildSystemType.GradleKotlinDsl,
buildFileData = BuildFileData( buildFileData = BuildFileData(
@@ -21,10 +21,10 @@ import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.*
import java.nio.file.Path import java.nio.file.Path
class KotlinPlugin(context: Context) : Plugin(context) { class KotlinPlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "kotlin" override val pluginPath = "kotlin"
private val moduleDependenciesValidator = settingValidator<List<Module>> { modules -> private val moduleDependenciesValidator = settingValidator<List<Module>> { modules ->
val allModules = modules.withAllSubModules(includeSourcesets = true).toSet() val allModules = modules.withAllSubModules(includeSourcesets = true).toSet()
@@ -47,12 +47,11 @@ class KotlinPlugin(context: Context) : Plugin(context) {
} }
val version by property( val version by property(
PATH,
// todo do not hardcode kind & repository // todo do not hardcode kind & repository
WizardKotlinVersion(Versions.KOTLIN, KotlinVersionKind.M, Repositories.KOTLIN_EAP_BINTRAY) WizardKotlinVersion(Versions.KOTLIN, KotlinVersionKind.M, Repositories.KOTLIN_EAP_BINTRAY)
) )
val initKotlinVersions by pipelineTask(PATH, GenerationPhase.PREPARE_GENERATION) { val initKotlinVersions by pipelineTask(GenerationPhase.PREPARE_GENERATION) {
title = KotlinNewProjectWizardBundle.message("plugin.kotlin.downloading.kotlin.versions") title = KotlinNewProjectWizardBundle.message("plugin.kotlin.downloading.kotlin.versions")
withAction { withAction {
@@ -64,7 +63,6 @@ class KotlinPlugin(context: Context) : Plugin(context) {
val projectKind by enumSetting<ProjectKind>( val projectKind by enumSetting<ProjectKind>(
KotlinNewProjectWizardBundle.message("plugin.kotlin.setting.project.kind"), KotlinNewProjectWizardBundle.message("plugin.kotlin.setting.project.kind"),
GenerationPhase.FIRST_STEP, GenerationPhase.FIRST_STEP,
PATH
) )
private fun List<Module>.findDuplicatesByName() = private fun List<Module>.findDuplicatesByName() =
@@ -74,7 +72,6 @@ class KotlinPlugin(context: Context) : Plugin(context) {
KotlinNewProjectWizardBundle.message("plugin.kotlin.setting.modules"), KotlinNewProjectWizardBundle.message("plugin.kotlin.setting.modules"),
GenerationPhase.SECOND_STEP, GenerationPhase.SECOND_STEP,
Module.parser, Module.parser,
PATH
) { ) {
validate { value -> validate { value ->
val allModules = value.withAllSubModules() val allModules = value.withAllSubModules()
@@ -106,7 +103,7 @@ class KotlinPlugin(context: Context) : Plugin(context) {
validate(moduleDependenciesValidator) validate(moduleDependenciesValidator)
} }
val createModules by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createModules by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(BuildSystemPlugin.createModules) runBefore(BuildSystemPlugin.createModules)
runAfter(StructurePlugin.createProjectDir) runAfter(StructurePlugin.createProjectDir)
withAction { withAction {
@@ -118,7 +115,7 @@ class KotlinPlugin(context: Context) : Plugin(context) {
} }
} }
val createPluginRepositories by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createPluginRepositories by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(BuildSystemPlugin.createModules) runBefore(BuildSystemPlugin.createModules)
withAction { withAction {
val version = version.propertyValue val version = version.propertyValue
@@ -131,7 +128,7 @@ class KotlinPlugin(context: Context) : Plugin(context) {
} }
} }
val createSourcesetDirectories by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val createSourcesetDirectories by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
withAction { withAction {
fun Path.createKotlinAndResourceDirectories(moduleConfigurator: ModuleConfigurator) = fun Path.createKotlinAndResourceDirectories(moduleConfigurator: ModuleConfigurator) =
@@ -12,10 +12,10 @@ import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.withAllSubModules
import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate import org.jetbrains.kotlin.tools.projectWizard.projectTemplates.ProjectTemplate
class ProjectTemplatesPlugin(context: Context) : Plugin(context) { class ProjectTemplatesPlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
const val PATH = "projectTemplates" override val pluginPath = "projectTemplates"
val template by dropDownSetting<ProjectTemplate>( val template by dropDownSetting<ProjectTemplate>(
KotlinNewProjectWizardBundle.message("plugin.templates.setting.template"), KotlinNewProjectWizardBundle.message("plugin.templates.setting.template"),
@@ -23,7 +23,6 @@ class ProjectTemplatesPlugin(context: Context) : Plugin(context) {
parser = valueParserM { _, _ -> parser = valueParserM { _, _ ->
Failure(ParseError("Project templates is not supported in yaml for now")) Failure(ParseError("Project templates is not supported in yaml for now"))
}, },
PATH
) { ) {
values = ProjectTemplate.ALL values = ProjectTemplate.ALL
isRequired = false isRequired = false
@@ -1,17 +1,18 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.templates package org.jetbrains.kotlin.tools.projectWizard.plugins.templates
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.templates.ConsoleJvmApplicationTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.ConsoleJvmApplicationTemplate
class ConsoleJvmApplicationTemplatePlugin(context: Context) : TemplatePlugin(context) { class ConsoleJvmApplicationTemplatePlugin(context: Context) : TemplatePlugin(context) {
override val path = PATH override val path = pluginPath
override val pipelineTasks: List<PipelineTask> = super.pipelineTasks + listOf(addTemplate) override val pipelineTasks: List<PipelineTask> = super.pipelineTasks + listOf(addTemplate)
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "template.consoleJvmApplicationTemplate" override val pluginPath = "template.consoleJvmApplicationTemplate"
val addTemplate by addTemplateTask(PATH, ConsoleJvmApplicationTemplate()) val addTemplate by addTemplateTask(ConsoleJvmApplicationTemplate())
} }
} }
@@ -1,20 +1,21 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.templates package org.jetbrains.kotlin.tools.projectWizard.plugins.templates
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.templates.SimpleJsClientTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.SimpleJsClientTemplate
class JsTemplatesPlugin(context: Context) : TemplatePlugin(context) { class JsTemplatesPlugin(context: Context) : TemplatePlugin(context) {
override val path = PATH override val path = pluginPath
override val pipelineTasks: List<PipelineTask> = super.pipelineTasks + override val pipelineTasks: List<PipelineTask> = super.pipelineTasks +
listOf( listOf(
addTemplate, addTemplate,
) )
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "template.jsTemplates" override val pluginPath = "template.jsTemplates"
val addTemplate by addTemplateTask(PATH, SimpleJsClientTemplate()) val addTemplate by addTemplateTask(SimpleJsClientTemplate())
} }
} }
@@ -1,20 +1,21 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.templates package org.jetbrains.kotlin.tools.projectWizard.plugins.templates
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.templates.KtorServerTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.KtorServerTemplate
class KtorTemplatesPlugin(context: Context) : TemplatePlugin(context) { class KtorTemplatesPlugin(context: Context) : TemplatePlugin(context) {
override val path = PATH override val path = pluginPath
override val pipelineTasks: List<PipelineTask> = super.pipelineTasks + override val pipelineTasks: List<PipelineTask> = super.pipelineTasks +
listOf( listOf(
addTemplate, addTemplate,
) )
companion object { companion object: PluginSettingsOwner() {
private const val PATH = "template.ktorTemplates" override val pluginPath = "template.ktorTemplates"
val addTemplate by addTemplateTask(PATH, KtorServerTemplate()) val addTemplate by addTemplateTask(KtorServerTemplate())
} }
} }
@@ -6,20 +6,21 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.templates package org.jetbrains.kotlin.tools.projectWizard.plugins.templates
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.templates.NativeConsoleApplicationTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.NativeConsoleApplicationTemplate
class NativeConsoleApplicationTemplatePlugin(context: Context) : TemplatePlugin(context) { class NativeConsoleApplicationTemplatePlugin(context: Context) : TemplatePlugin(context) {
override val path = PATH override val path = pluginPath
override val pipelineTasks: List<PipelineTask> = super.pipelineTasks + override val pipelineTasks: List<PipelineTask> = super.pipelineTasks +
listOf( listOf(
addTemplate, addTemplate,
) )
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "template.nativeConsoleApplicationTemplate" override val pluginPath = "template.nativeConsoleApplicationTemplate"
val addTemplate by addTemplateTask(PATH, NativeConsoleApplicationTemplate()) val addTemplate by addTemplateTask( NativeConsoleApplicationTemplate())
} }
} }
@@ -6,24 +6,24 @@
package org.jetbrains.kotlin.tools.projectWizard.plugins.templates package org.jetbrains.kotlin.tools.projectWizard.plugins.templates
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask import org.jetbrains.kotlin.tools.projectWizard.core.entity.PipelineTask
import org.jetbrains.kotlin.tools.projectWizard.templates.KtorServerTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.KtorServerTemplate
import org.jetbrains.kotlin.tools.projectWizard.templates.SimpleJsClientTemplate
import org.jetbrains.kotlin.tools.projectWizard.templates.SimpleNodeJsTemplate import org.jetbrains.kotlin.tools.projectWizard.templates.SimpleNodeJsTemplate
class SimpleNodeJsTemplatesPlugin(context: Context) : TemplatePlugin(context) { class SimpleNodeJsTemplatesPlugin(context: Context) : TemplatePlugin(context) {
override val path = PATH override val path = pluginPath
override val pipelineTasks: List<PipelineTask> = super.pipelineTasks + override val pipelineTasks: List<PipelineTask> = super.pipelineTasks +
listOf( listOf(
KtorTemplatesPlugin.addTemplate, KtorTemplatesPlugin.addTemplate,
) )
val addTemplate by addTemplateTask(PATH, SimpleNodeJsTemplate()) val addTemplate by addTemplateTask(SimpleNodeJsTemplate())
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "template.simpleNodeJs" override val pluginPath = "template.simpleNodeJs"
val addTemplate by addTemplateTask(PATH, KtorServerTemplate()) val addTemplate by addTemplateTask(KtorServerTemplate())
} }
} }
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.tools.projectWizard.plugins.templates
import org.jetbrains.kotlin.tools.projectWizard.core.Context import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.Plugin import org.jetbrains.kotlin.tools.projectWizard.core.Plugin
import org.jetbrains.kotlin.tools.projectWizard.core.PluginSettingsOwner
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.Property import org.jetbrains.kotlin.tools.projectWizard.core.entity.Property
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.PluginSetting
@@ -9,16 +10,16 @@ import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
import org.jetbrains.kotlin.tools.projectWizard.templates.Template import org.jetbrains.kotlin.tools.projectWizard.templates.Template
abstract class TemplatePlugin(context: Context) : Plugin(context) { abstract class TemplatePlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
override val settings: List<PluginSetting<*, *>> = emptyList() override val settings: List<PluginSetting<*, *>> = emptyList()
override val pipelineTasks: List<PipelineTask> = emptyList() override val pipelineTasks: List<PipelineTask> = emptyList()
override val properties: List<Property<*>> = emptyList() override val properties: List<Property<*>> = emptyList()
companion object { companion object : PluginSettingsOwner() {
const val PATH = "template" override val pluginPath = "template"
fun addTemplateTask(prefix: String, template: Template) = pipelineTask(prefix, GenerationPhase.PREPARE) { fun addTemplateTask(template: Template) = pipelineTask(GenerationPhase.PREPARE) {
withAction { withAction {
TemplatesPlugin.addTemplate.execute(template) TemplatesPlugin.addTemplate.execute(template)
} }
@@ -24,37 +24,34 @@ import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.settingValue
import java.nio.file.Path import java.nio.file.Path
class TemplatesPlugin(context: Context) : Plugin(context) { class TemplatesPlugin(context: Context) : Plugin(context) {
override val path = PATH override val path = pluginPath
companion object { companion object : PluginSettingsOwner() {
private const val PATH = "templates" override val pluginPath = "templates"
val templates by property<Map<String, Template>>( val templates by property<Map<String, Template>>(emptyMap())
PATH,
emptyMap()
)
val addTemplate by task1<Template, Unit>(PATH) { val addTemplate by task1<Template, Unit> {
withAction { template -> withAction { template ->
templates.update { success(it + (template.id to template)) } templates.update { success(it + (template.id to template)) }
} }
} }
val fileTemplatesToRender by property<List<FileTemplate>>(PATH, emptyList()) val fileTemplatesToRender by property<List<FileTemplate>>(emptyList())
val addFileTemplate by task1<FileTemplate, Unit>(PATH) { val addFileTemplate by task1<FileTemplate, Unit> {
withAction { template -> withAction { template ->
fileTemplatesToRender.update { success(it + template) } fileTemplatesToRender.update { success(it + template) }
} }
} }
val addFileTemplates by task1<List<FileTemplate>, Unit>(PATH) { val addFileTemplates by task1<List<FileTemplate>, Unit> {
withAction { templates -> withAction { templates ->
fileTemplatesToRender.addValues(templates) fileTemplatesToRender.addValues(templates)
} }
} }
val renderFileTemplates by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val renderFileTemplates by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
withAction { withAction {
val templateEngine = service<TemplateEngineService>() val templateEngine = service<TemplateEngineService>()
@@ -64,7 +61,7 @@ class TemplatesPlugin(context: Context) : Plugin(context) {
} }
} }
val addTemplatesToModules by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val addTemplatesToModules by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(BuildSystemPlugin.createModules) runBefore(BuildSystemPlugin.createModules)
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
@@ -92,7 +89,7 @@ class TemplatesPlugin(context: Context) : Plugin(context) {
} }
} }
val postApplyTemplatesToModules by pipelineTask(PATH, GenerationPhase.PROJECT_GENERATION) { val postApplyTemplatesToModules by pipelineTask(GenerationPhase.PROJECT_GENERATION) {
runBefore(BuildSystemPlugin.createModules) runBefore(BuildSystemPlugin.createModules)
runAfter(KotlinPlugin.createModules) runAfter(KotlinPlugin.createModules)
runAfter(TemplatesPlugin.addTemplatesToModules) runAfter(TemplatesPlugin.addTemplatesToModules)
@@ -66,7 +66,6 @@ fun <V : Any, T : SettingType<V>> Reader.settingValue(module: Module, setting: T
abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSettingItem { abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSettingItem {
final override fun <V : Any, T : SettingType<V>> settingDelegate( final override fun <V : Any, T : SettingType<V>> settingDelegate(
prefix: String,
create: (path: String) -> SettingBuilder<V, T> create: (path: String) -> SettingBuilder<V, T>
): ReadOnlyProperty<Any, TemplateSetting<V, T>> = cached { name -> ): ReadOnlyProperty<Any, TemplateSetting<V, T>> = cached { name ->
TemplateSetting(create(name).buildInternal()) TemplateSetting(create(name).buildInternal())
@@ -158,14 +157,12 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String,
init: DropDownSettingType.Builder<V>.() -> Unit init: DropDownSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<V, DropDownSettingType<V>>> = ): ReadOnlyProperty<Any, TemplateSetting<V, DropDownSettingType<V>>> =
super.dropDownSetting( super.dropDownSetting(
title, title,
neededAtPhase, neededAtPhase,
parser, parser,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<V, DropDownSettingType<V>>> ) as ReadOnlyProperty<Any, TemplateSetting<V, DropDownSettingType<V>>>
@@ -173,13 +170,11 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
final override fun stringSetting( final override fun stringSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: StringSettingType.Builder.() -> Unit init: StringSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<String, StringSettingType>> = ): ReadOnlyProperty<Any, TemplateSetting<String, StringSettingType>> =
super.stringSetting( super.stringSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<String, StringSettingType>> ) as ReadOnlyProperty<Any, TemplateSetting<String, StringSettingType>>
@@ -187,13 +182,11 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
final override fun booleanSetting( final override fun booleanSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: BooleanSettingType.Builder.() -> Unit init: BooleanSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<Boolean, BooleanSettingType>> = ): ReadOnlyProperty<Any, TemplateSetting<Boolean, BooleanSettingType>> =
super.booleanSetting( super.booleanSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<Boolean, BooleanSettingType>> ) as ReadOnlyProperty<Any, TemplateSetting<Boolean, BooleanSettingType>>
@@ -202,14 +195,12 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String,
init: ValueSettingType.Builder<V>.() -> Unit init: ValueSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<V, ValueSettingType<V>>> = ): ReadOnlyProperty<Any, TemplateSetting<V, ValueSettingType<V>>> =
super.valueSetting( super.valueSetting(
title, title,
neededAtPhase, neededAtPhase,
parser, parser,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<V, ValueSettingType<V>>> ) as ReadOnlyProperty<Any, TemplateSetting<V, ValueSettingType<V>>>
@@ -217,13 +208,11 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
final override fun versionSetting( final override fun versionSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: VersionSettingType.Builder.() -> Unit init: VersionSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<Version, VersionSettingType>> = ): ReadOnlyProperty<Any, TemplateSetting<Version, VersionSettingType>> =
super.versionSetting( super.versionSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<Version, VersionSettingType>> ) as ReadOnlyProperty<Any, TemplateSetting<Version, VersionSettingType>>
@@ -232,14 +221,12 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
parser: Parser<V>, parser: Parser<V>,
prefix: String,
init: ListSettingType.Builder<V>.() -> Unit init: ListSettingType.Builder<V>.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<List<V>, ListSettingType<V>>> = ): ReadOnlyProperty<Any, TemplateSetting<List<V>, ListSettingType<V>>> =
super.listSetting( super.listSetting(
title, title,
neededAtPhase, neededAtPhase,
parser, parser,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<List<V>, ListSettingType<V>>> ) as ReadOnlyProperty<Any, TemplateSetting<List<V>, ListSettingType<V>>>
@@ -248,13 +235,11 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
final override fun pathSetting( final override fun pathSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String,
init: PathSettingType.Builder.() -> Unit init: PathSettingType.Builder.() -> Unit
): ReadOnlyProperty<Any, TemplateSetting<Path, PathSettingType>> = ): ReadOnlyProperty<Any, TemplateSetting<Path, PathSettingType>> =
super.pathSetting( super.pathSetting(
title, title,
neededAtPhase, neededAtPhase,
prefix,
init init
) as ReadOnlyProperty<Any, TemplateSetting<Path, PathSettingType>> ) as ReadOnlyProperty<Any, TemplateSetting<Path, PathSettingType>>
@@ -262,10 +247,9 @@ abstract class Template : SettingsOwner, EntitiesOwnerDescriptor, DisplayableSet
inline fun <reified E> enumSetting( inline fun <reified E> enumSetting(
title: String, title: String,
neededAtPhase: GenerationPhase, neededAtPhase: GenerationPhase,
prefix: String = "",
crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {} crossinline init: DropDownSettingType.Builder<E>.() -> Unit = {}
): ReadOnlyProperty<Any, TemplateSetting<E, DropDownSettingType<E>>> where E : Enum<E>, E : DisplayableSettingItem = ): ReadOnlyProperty<Any, TemplateSetting<E, DropDownSettingType<E>>> where E : Enum<E>, E : DisplayableSettingItem =
enumSettingImpl(title, neededAtPhase, prefix, init) as ReadOnlyProperty<Any, TemplateSetting<E, DropDownSettingType<E>>> enumSettingImpl(title, neededAtPhase, init) as ReadOnlyProperty<Any, TemplateSetting<E, DropDownSettingType<E>>>
companion object { companion object {
fun parser(templateId: Identificator): Parser<Template> = mapParser { map, path -> fun parser(templateId: Identificator): Parser<Template> = mapParser { map, path ->