Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quarkus support. #184

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ 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")
testImplementation("com.intellij.remoterobot:ide-launcher:0.11.19.414")
Expand Down Expand Up @@ -231,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
27 changes: 27 additions & 0 deletions modules/products/quarkus/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
fun properties(key: String) = project.findProperty(key).toString()

plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.8.22"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.+"
}

tasks {
buildSearchableOptions {
enabled = false
}
}

intellij {
type.set("IU")
//version.set(properties("platformVersion"))
version.set("2024.1")
plugins.set(listOf("java", "gradle", "maven", "com.intellij.quarkus:241.14494.158"))
}

dependencies {
implementation(project(":mirrord-core"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
@file:Suppress("UnstableApiUsage")

package com.metalbear.mirrord.products.quarkus

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 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 {
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(
applicableConfiguration: RunConfigurationBase<*>,
runnerSettings: RunnerSettings?
): Boolean {
return true
}

private fun <T : RunConfigurationBase<*>> getMirrordConfigPath(configuration: T, params: JavaParameters): String? {
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.
*/
override fun attachToProcess(
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<*>) {}
})
}
}
}

*/
15 changes: 8 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ 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"
)

// Rename modules to mirrord-<module>, I think this is required IntelliJ wise.
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/mirrord-quarkus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<idea-plugin>
<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>
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +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="mirrord-quarkus.xml">com.intellij.quarkus</depends>
<depends optional="true" config-file="mirrord-schema.xml">com.intellij.modules.json</depends>
</idea-plugin>
Loading