Skip to content

Commit

Permalink
Add node, ClassNotFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
t4lz committed Apr 14, 2023
1 parent 0484651 commit 4596f6a
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 1 deletion.
7 changes: 6 additions & 1 deletion intellij-ext/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ platformVersion = 2022.3
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = com.intellij.java
# "Cannot find builtin plugin 'JavaScriptLanguage' for IDE: ..."
# TODO!
#platformPlugins = com.intellij.java, JavaScriptLanguage

platformDownloadSources = true

# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 17
Expand All @@ -21,4 +26,4 @@ gradleVersion = 7.6
# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false
kotlin.stdlib.default.dependency = false
33 changes: 33 additions & 0 deletions intellij-ext/modules/products/webstorm/build.gradle.kts
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"))
}
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)
}
}
5 changes: 5 additions & 0 deletions intellij-ext/src/main/resources/META-INF/mirrord-js.xml
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>
1 change: 1 addition & 0 deletions intellij-ext/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@
<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">JavaScript</depends>

</idea-plugin>

0 comments on commit 4596f6a

Please sign in to comment.