Wizard: introduce ServicesManager & correctly handle disabled gradle & maven Idea plugins
This commit is contained in:
+9
-5
@@ -5,8 +5,7 @@ import org.jetbrains.kotlin.tools.projectWizard.core.*
|
||||
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.reference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.AndroidServiceImpl
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.Service
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.*
|
||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||
@@ -16,9 +15,14 @@ class YamlWizard(
|
||||
private val yaml: String,
|
||||
private val path: String,
|
||||
createPlugins: (Context) -> List<Plugin>
|
||||
) : Wizard(createPlugins, listOf(AndroidServiceImpl())) {
|
||||
) : Wizard(
|
||||
createPlugins,
|
||||
ServicesManager(Services.IDEA_INDEPENDENT_SERVICES) { services ->
|
||||
services.firstOrNull { it is IdeaIndependentWizardService }
|
||||
}
|
||||
) {
|
||||
override fun apply(
|
||||
services: List<Service>,
|
||||
services: List<WizardService>,
|
||||
phases: Set<GenerationPhase>,
|
||||
onTaskExecuting: (PipelineTask) -> Unit
|
||||
): TaskResult<Unit> = computeM {
|
||||
@@ -38,5 +42,5 @@ class YamlWizard(
|
||||
get() = pluginSettings.mapNotNull { setting ->
|
||||
val defaultValue = setting.defaultValue ?: return@mapNotNull null
|
||||
PluginSettingReference(setting) to defaultValue
|
||||
} .toMap()
|
||||
}.toMap()
|
||||
}
|
||||
|
||||
+1
-3
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.cli
|
||||
|
||||
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.onFailure
|
||||
@@ -20,7 +19,6 @@ import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
abstract class AbstractBuildFileGenerationTest : AbstractPluginBasedTest() {
|
||||
|
||||
fun doTest(directoryPath: String) {
|
||||
val directory = Paths.get(directoryPath)
|
||||
val testData = init(directory)
|
||||
@@ -41,7 +39,7 @@ abstract class AbstractBuildFileGenerationTest : AbstractPluginBasedTest() {
|
||||
buildSystem.yaml
|
||||
val tempDir = Files.createTempDirectory(null)
|
||||
val wizard = YamlWizard(yaml, tempDir.toString(), testData.createPlugins)
|
||||
val result = wizard.apply(Services.osServices, GenerationPhase.ALL)
|
||||
val result = wizard.apply(Services.IDEA_INDEPENDENT_SERVICES, GenerationPhase.ALL)
|
||||
result.onFailure { errors ->
|
||||
errors.forEach { error ->
|
||||
if (error is ExceptionError) {
|
||||
|
||||
Reference in New Issue
Block a user