mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin, gradle, kmt] KMT-2153: Add run configuration extension
Add a run configuration extension that indicates compose is used with Kotlin JVM Gradle plugin. It also stores the location of the main function that will be executed by the compose gradle run tasks. GitOrigin-RevId: a58f96d599a8a7ce6a1fc97f25b8cca3f9b281f5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7f11fb15c1
commit
27a405684d
@@ -93,6 +93,7 @@ jvm_library(
|
||||
"//platform/lang-api:lang",
|
||||
"//platform/execution",
|
||||
"//plugins/kotlin/base/indices",
|
||||
"//platform/util/jdom",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -183,6 +184,7 @@ jvm_library(
|
||||
"//platform/lang-api:lang",
|
||||
"//platform/execution",
|
||||
"//plugins/kotlin/base/indices",
|
||||
"//platform/util/jdom",
|
||||
]
|
||||
)
|
||||
### auto-generated section `build kotlin.gradle.gradle-java` end
|
||||
|
||||
@@ -95,5 +95,6 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.lang" />
|
||||
<orderEntry type="module" module-name="intellij.platform.execution" />
|
||||
<orderEntry type="module" module-name="intellij.kotlin.base.indices" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.jdom" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -109,6 +109,8 @@
|
||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.gradleJava.testing.KotlinAllInPackageGradleConfigurationProducer"
|
||||
order="before allInPackageGradleConfigurationProducer"/>
|
||||
|
||||
<externalSystem.runConfigurationEx implementation="org.jetbrains.kotlin.idea.gradleJava.run.ComposeJvmRunConfigurationExtension"/>
|
||||
|
||||
<registryKey
|
||||
key="kotlin.gradle.testing.enabled"
|
||||
description="Import Kotlin Gradle test tasks and process test output"
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.gradleJava.run
|
||||
|
||||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration
|
||||
import com.intellij.openapi.externalSystem.service.execution.configuration.ExternalSystemReifiedRunConfigurationExtension
|
||||
import com.intellij.openapi.externalSystem.service.execution.configuration.fragments.SettingsEditorFragmentContainer
|
||||
import com.intellij.openapi.externalSystem.service.execution.configuration.fragments.addRemovableLabeledTextSettingsEditorFragment
|
||||
import com.intellij.openapi.externalSystem.service.ui.util.LabeledSettingsFragmentInfo
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.ui.components.JBTextField
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.kotlin.idea.gradleJava.KotlinJavaGradleBundle
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration
|
||||
|
||||
private val isComposeJvmKey = Key.create<Boolean>("isComposeJvm")
|
||||
private val mainFunctionClassFqnKey = Key.create<String>("mainClassFqn")
|
||||
|
||||
internal var ExternalSystemRunConfiguration.isComposeJvm: Boolean
|
||||
get() = getUserData<Boolean>(isComposeJvmKey) == true
|
||||
set(value) = putUserData<Boolean>(isComposeJvmKey, value)
|
||||
|
||||
internal var ExternalSystemRunConfiguration.mainFunctionClassFqn: String?
|
||||
get() = getUserData<String>(mainFunctionClassFqnKey) as? String
|
||||
set(value) = putUserData<String>(mainFunctionClassFqnKey, value)
|
||||
|
||||
|
||||
internal class ComposeJvmRunConfigurationExtension :
|
||||
ExternalSystemReifiedRunConfigurationExtension<GradleRunConfiguration>(GradleRunConfiguration::class.java) {
|
||||
|
||||
private companion object {
|
||||
const val ROOT_KEY = "ComposeJvm"
|
||||
const val MAIN_FUNCTION_FILE_KEY = "mainFunctionFile"
|
||||
}
|
||||
|
||||
override fun SettingsEditorFragmentContainer<GradleRunConfiguration>.configureFragments(
|
||||
configuration: GradleRunConfiguration
|
||||
) {
|
||||
// fragment will only be visible + accessible if set programmatically for this run configuration
|
||||
if (!configuration.isComposeJvm) return
|
||||
|
||||
addRemovableLabeledTextSettingsEditorFragment(
|
||||
settingsFragmentInfo = object : LabeledSettingsFragmentInfo {
|
||||
override val editorLabel: String = KotlinJavaGradleBundle.message("settings.run.configuration.compose.jvm.main.class.name")
|
||||
override val settingsId: String = "compose.jvm.main.class.fragment"
|
||||
override val settingsName: String = KotlinJavaGradleBundle.message("settings.run.configuration.compose.jvm.main.class.name")
|
||||
override val settingsGroup: String = KotlinJavaGradleBundle.message("settings.run.configuration.compose.jvm.main.class.group")
|
||||
override val settingsHint: String = KotlinJavaGradleBundle.message("settings.run.configuration.compose.jvm.main.class.hint")
|
||||
override val settingsActionHint: String? = null
|
||||
},
|
||||
createComponent = { JBTextField() },
|
||||
getter = { configuration.mainFunctionClassFqn },
|
||||
setter = { configuration.mainFunctionClassFqn = it ?: "" },
|
||||
default = { null })
|
||||
}
|
||||
|
||||
override fun writeExternal(runConfiguration: ExternalSystemRunConfiguration, element: Element) {
|
||||
super.writeExternal(runConfiguration, element)
|
||||
if (!runConfiguration.isComposeJvm) return
|
||||
|
||||
element.addContent(Element(ROOT_KEY).apply {
|
||||
addContent(Element(MAIN_FUNCTION_FILE_KEY).apply { text = runConfiguration.mainFunctionClassFqn })
|
||||
})
|
||||
}
|
||||
|
||||
override fun readExternal(runConfiguration: ExternalSystemRunConfiguration, element: Element) {
|
||||
super.readExternal(runConfiguration, element)
|
||||
val myElement = element.getChild(ROOT_KEY) ?: return
|
||||
|
||||
runConfiguration.isComposeJvm = true
|
||||
runConfiguration.mainFunctionClassFqn = myElement.getChild(MAIN_FUNCTION_FILE_KEY)?.text ?: ""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user