-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
fun properties(key: String) = project.findProperty(key).toString() | ||
|
||
plugins { | ||
// Java support | ||
id("java") | ||
// Kotlin support | ||
id("org.jetbrains.kotlin.jvm") version "1.8.10" | ||
// Gradle IntelliJ Plugin | ||
id("org.jetbrains.intellij") version "1.+" | ||
|
||
} | ||
|
||
tasks { | ||
buildSearchableOptions { | ||
enabled = false | ||
} | ||
} | ||
|
||
intellij { | ||
type.set("IU") | ||
// version.set("192.7142.36") | ||
version.set(properties("platformVersion")) | ||
plugins.set(listOf("JavaScriptLanguage", "NodeJS")) | ||
} | ||
|
||
runIde { | ||
// TODO: something | ||
ideDir.set("/Users/$USERNAME/Library/Application Support/JetBrains/Toolbox/apps/WebStorm/ch-0/231.8109.174/WebStorm.app/Contents") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":mirrord-core")) | ||
} |
84 changes: 84 additions & 0 deletions
84
.../src/main/kotlin/com/metalbear/mirrord/products/webstorm/NodeRunConfigurationExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.metalbear.mirrord.products.webstorm | ||
|
||
import com.intellij.execution.Executor | ||
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.target.createEnvironmentRequest | ||
import com.intellij.execution.wsl.target.WslTargetEnvironmentRequest | ||
import com.intellij.javascript.nodejs.execution.runConfiguration.AbstractNodeRunConfigurationExtension; | ||
import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration | ||
import com.metalbear.mirrord.MirrordExecManager | ||
import com.metalbear.mirrord.MirrordLogger | ||
|
||
|
||
class NodeRunConfigurationExtension: AbstractNodeRunConfigurationExtension() { | ||
override fun isApplicableFor(configuration: RunConfigurationBase<*>): Boolean { | ||
return true | ||
} | ||
|
||
|
||
override fun isEnabledFor( | ||
applicableConfiguration: RunConfigurationBase<*>, | ||
runnerSettings: RunnerSettings? | ||
): Boolean { | ||
return true | ||
} | ||
|
||
|
||
private fun < T: RunConfigurationBase<*>> patchEnv (configuration: T, params: JavaParameters) { | ||
MirrordLogger.logger.debug("Check if relevant") | ||
if (configuration.name.startsWith("Build ")) { | ||
MirrordLogger.logger.info("Configuration name %s ignored".format(configuration.name)) | ||
return | ||
} | ||
MirrordLogger.logger.debug("wsl check") | ||
val wsl = when (val request = createEnvironmentRequest(configuration, configuration.project)) { | ||
is WslTargetEnvironmentRequest -> request.configuration.distribution!! | ||
else -> null | ||
} | ||
|
||
MirrordLogger.logger.debug("getting env") | ||
val project = configuration.project | ||
val currentEnv = HashMap<String, String>() | ||
currentEnv.putAll(params.env) | ||
|
||
val mirrordEnv = HashMap<String, String>() | ||
MirrordLogger.logger.debug("calling start") | ||
MirrordExecManager.start(wsl, project)?.let { | ||
env -> | ||
for (entry in env.entries.iterator()) { | ||
mirrordEnv[entry.key] = entry.value | ||
} | ||
} | ||
|
||
params.env = currentEnv + mirrordEnv | ||
|
||
// Gradle support (and external system configuration) | ||
if (configuration is ExternalSystemRunConfiguration) { | ||
val ext = configuration as ExternalSystemRunConfiguration | ||
val newEnv = ext.settings.env + mirrordEnv | ||
ext.settings.env = newEnv | ||
} | ||
MirrordLogger.logger.debug("setting env and finishing") | ||
} | ||
override fun <T : RunConfigurationBase<*>> updateJavaParameters( | ||
configuration: T, | ||
params: JavaParameters, | ||
runnerSettings: RunnerSettings?, | ||
executor: Executor | ||
) { | ||
MirrordLogger.logger.debug("updateJavaParameters called") | ||
patchEnv(configuration, params) | ||
} | ||
|
||
override fun <T : RunConfigurationBase<*>> updateJavaParameters( | ||
configuration: T, | ||
params: JavaParameters, | ||
runnerSettings: RunnerSettings? | ||
) { | ||
MirrordLogger.logger.debug("updateJavaParameters (with less parameters) called") | ||
patchEnv(configuration, params) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<idea-plugin> | ||
<extensions defaultExtensionNs="JavaScript"> | ||
<nodeRunConfigurationExtension implementation="com.metalbear.mirrord.products.webstorm.NodeRunConfigurationExtension" id="mirrordJS"/> | ||
</extensions> | ||
</idea-plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters