Skip to content

Commit

Permalink
messy, quarkus impl
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed May 16, 2024
1 parent 6d70dfb commit ca4ba24
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 17 deletions.
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ repositories {
val remoteRobotVersion = "0.11.19"

dependencies {
/*
implementation(project(":mirrord-products-idea"))
implementation(project(":mirrord-products-pycharm"))
implementation(project(":mirrord-products-rubymine"))
implementation(project(":mirrord-products-goland"))
implementation(project(":mirrord-products-nodejs"))
implementation(project(":mirrord-products-rider"))
implementation(project(":mirrord-products-tomcat"))
*/
implementation(project(":mirrord-products-quarkus"))
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
Expand Down Expand Up @@ -232,7 +234,8 @@ tasks {
listProductsReleases {
val ides = System.getenv("IDE")
types.set(ides?.split(',') ?: listOf("IU", "RD", "PY"))
sinceBuild.set(if (types.get() == listOf("IU")) "222.*" else "232.*")
//sinceBuild.set(if (types.get() == listOf("IU")) "222.*" else "232.*")
sinceBuild.set("241.*")
releaseChannels.set(setOf(ListProductsReleasesTask.Channel.EAP, ListProductsReleasesTask.Channel.RELEASE))
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pluginName = mirrord
# SemVer format -> https://semver.org
pluginVersion = 3.60.1

platformVersion = 2022.3.2
platformVersion = 2024.1.1

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class MirrordExecManager(private val service: MirrordProjectService) {

chooseTarget(cli, wslDistribution, configPath, mirrordApi)
.takeUnless { it == MirrordExecDialog.targetlessTargetName }
/*
.alsoIfNull {
MirrordLogger.logger.info("No target specified - running targetless")
service.notifier.notification(
Expand All @@ -179,6 +180,7 @@ class MirrordExecManager(private val service: MirrordProjectService) {
.withDontShowAgain(MirrordSettingsState.NotificationId.RUNNING_TARGETLESS)
.fire()
}
*/
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,68 @@ import com.intellij.execution.RunConfigurationExtension
import com.intellij.execution.configurations.JavaParameters
import com.intellij.execution.configurations.RunConfigurationBase
import com.intellij.execution.configurations.RunnerSettings
import com.intellij.execution.process.ProcessEvent
import com.intellij.execution.process.ProcessHandler
import com.intellij.execution.process.ProcessListener
import com.intellij.execution.target.*
import com.intellij.execution.target.value.TargetValue
import com.intellij.execution.wsl.target.WslTargetEnvironmentRequest
import com.intellij.openapi.components.service
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.quarkus.run.QsLocalRepoRootHolder
import java.util.concurrent.ConcurrentHashMap
//import com.intellij.quarkus.run.QsTargetConfigurationExtension
//import com.intellij.quarkus.run.QsTargetConfigurationExtension
import com.intellij.quarkus.run.QsTargetConfigurationExtension
// import com.intellij.quarkus.run.maven.QsMavenRunConfiguration
import com.metalbear.mirrord.CONFIG_ENV_NAME
import com.metalbear.mirrord.MirrordLogger
import com.metalbear.mirrord.MirrordProjectService
import java.util.function.Consumer

class QuarkusRunConfigurationExtension : QsTargetConfigurationExtension {
override fun customizeCommandLine(
targetConfiguration: TargetEnvironmentConfiguration,
commandLine: TargetedCommandLineBuilder,
attachDebugger: Boolean
) {
println("targetConfig $targetConfiguration")
println("commandLine $commandLine")
println("debugger $attachDebugger")

TODO("Not yet implemented")
}

override fun prepareTargetLocalRepo(
request: TargetEnvironmentRequest,
targetConfiguration: TargetEnvironmentConfiguration,
holder: QsLocalRepoRootHolder
): Pair<TargetValue<String>, Consumer<TargetEnvironment>>? {
println("request $request")
println("targetConfiguration $targetConfiguration")
println("holder $holder")
TODO("Not yet implemented")
}
}


class QuarkusRunConfigurationExtension : RunConfigurationExtension() {
/*
class IdeaRunConfigurationExtension : RunConfigurationExtension() {
/**
* mirrord env set in ExternalRunConfigurations. Used for cleanup the configuration after the execution has ended.
*/
private val runningProcessEnvs = ConcurrentHashMap<Project, Map<String, String>>()
override fun isApplicableFor(configuration: RunConfigurationBase<*>): Boolean {
return true
val applicable = !configuration.name.startsWith("Build ") && !configuration.name.startsWith("Tomcat")
if (!applicable) {
MirrordLogger.logger.info("Configuration name %s ignored".format(configuration.name))
}
return applicable
}
override fun isEnabledFor(
Expand All @@ -30,14 +78,56 @@ class QuarkusRunConfigurationExtension : RunConfigurationExtension() {
}
private fun <T : RunConfigurationBase<*>> getMirrordConfigPath(configuration: T, params: JavaParameters): String? {
return null
return params.env[CONFIG_ENV_NAME] ?: if (configuration is ExternalSystemRunConfiguration) {
val ext = configuration as ExternalSystemRunConfiguration
ext.settings.env[CONFIG_ENV_NAME]
} else {
null
}
}
override fun <T : RunConfigurationBase<*>> updateJavaParameters(
configuration: T,
params: JavaParameters,
runnerSettings: RunnerSettings?
) { }
) {
val service = configuration.project.service<MirrordProjectService>()
MirrordLogger.logger.debug("wsl check")
val wsl = when (val request = createEnvironmentRequest(configuration, configuration.project)) {
is WslTargetEnvironmentRequest -> request.configuration.distribution!!
else -> null
}
val extraEnv = if (configuration is ExternalSystemRunConfiguration) {
val extraEnv = params.env + configuration.settings.env
extraEnv
} else {
params.env
}
service.execManager.wrapper("idea", extraEnv).apply {
this.wsl = wsl
}.start()?.let { executionInfo ->
val mirrordEnv = executionInfo.environment + mapOf(Pair("MIRRORD_DETECT_DEBUGGER_PORT", "javaagent"))
params.env = params.env + mirrordEnv
executionInfo.envToUnset?.let { keys ->
params.env = params.env.filterKeys { !keys.contains(it) }
}
runningProcessEnvs[configuration.project] = params.env.toMap()
// Gradle support (and external system configuration)
if (configuration is ExternalSystemRunConfiguration) {
runningProcessEnvs[configuration.project] = configuration.settings.env.toMap()
var env = configuration.settings.env + mirrordEnv
executionInfo.envToUnset?.let { keys ->
env = env.filterKeys { !keys.contains(it) }
}
configuration.settings.env = configuration.settings.env + mirrordEnv
}
MirrordLogger.logger.debug("setting env and finishing")
}
}
/**
* Remove mirrord env leftovers from the external system configurations.
Expand All @@ -46,5 +136,42 @@ class QuarkusRunConfigurationExtension : RunConfigurationExtension() {
configuration: RunConfigurationBase<*>,
handler: ProcessHandler,
runnerSettings: RunnerSettings?
) { }
) {
if (configuration is QsTargetConfigurationExtension) {
val envsToRestore = runningProcessEnvs.remove(configuration.project) ?: return
handler.addProcessListener(object : ProcessListener {
/*
override fun processTerminated(event: ProcessEvent) {
configuration.settings.env.apply {
clear()
putAll(envsToRestore)
}
}
*/
override fun startNotified(event: ProcessEvent) {}
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {}
})
}
if (configuration is ExternalSystemRunConfiguration) {
val envsToRestore = runningProcessEnvs.remove(configuration.project) ?: return
handler.addProcessListener(object : ProcessListener {
override fun processTerminated(event: ProcessEvent) {
configuration.settings.env.apply {
clear()
putAll(envsToRestore)
}
}
override fun startNotified(event: ProcessEvent) {}
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {}
})
}
}
}
*/
14 changes: 7 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ rootProject.name = "mirrord"

include(
"modules/core",
"modules/products/idea",
"modules/products/goland",
"modules/products/pycharm",
"modules/products/rubymine",
"modules/products/nodejs",
"modules/products/rider",
"modules/products/tomcat",
// "modules/products/idea",
// "modules/products/goland",
// "modules/products/pycharm",
// "modules/products/rubymine",
// "modules/products/nodejs",
// "modules/products/rider",
// "modules/products/tomcat",
"modules/products/quarkus"
)

Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/META-INF/mirrord-quarkus.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<runConfigurationExtension implementation="com.metalbear.mirrord.products.quarkus.QuarkusRunConfigurationExtension" id="mirrordQuarkus"/>
<extensions defaultExtensionNs="com.intellij.quarkus">
<targetConfigurationExtension implementation="com.metalbear.mirrord.products.quarkus.QuarkusRunConfigurationExtension" id="mirrordQuarkus"/>
<!--runConfigurationExtension implementation="com.metalbear.mirrord.products.quarkus.IdeaRunConfigurationExtension" id="mirrordQuarkus"/-->
</extensions>
</idea-plugin>
4 changes: 3 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@
</group>
</actions>

<!--
<depends optional="true" config-file="mirrord-idea.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="mirrord-pycharm.xml">com.intellij.modules.python</depends>
<depends optional="true" config-file="mirrord-rubymine.xml">com.intellij.modules.ruby</depends>
<depends optional="true" config-file="mirrord-goland.xml">org.jetbrains.plugins.go</depends>
<depends optional="true" config-file="mirrord-js.xml">NodeJS</depends>
<depends optional="true" config-file="mirrord-rider.xml">com.intellij.modules.rider</depends>
<depends optional="true" config-file="mirrord-tomcat.xml">Tomcat</depends>
<depends optional="true" config-file="META-INF/mirrord-quarkus.xml">com.intellij.quarkus</depends>
-->
<depends optional="true" config-file="mirrord-quarkus.xml">com.intellij.quarkus</depends>
<depends optional="true" config-file="mirrord-schema.xml">com.intellij.modules.json</depends>
</idea-plugin>

0 comments on commit ca4ba24

Please sign in to comment.