Shutting down daemon from kotlin plugin on idea exit, passing jvm params to daemon launch
This commit is contained in:
Generated
+2
@@ -44,6 +44,8 @@
|
|||||||
<element id="module-output" name="idea-core" />
|
<element id="module-output" name="idea-core" />
|
||||||
<element id="module-output" name="idea-js" />
|
<element id="module-output" name="idea-js" />
|
||||||
<element id="module-output" name="container" />
|
<element id="module-output" name="container" />
|
||||||
|
<element id="module-output" name="rmi-interface" />
|
||||||
|
<element id="module-output" name="kotlinr" />
|
||||||
</element>
|
</element>
|
||||||
<element id="library" level="project" name="javax.inject" />
|
<element id="library" level="project" name="javax.inject" />
|
||||||
<element id="directory" name="jps">
|
<element id="directory" name="jps">
|
||||||
|
|||||||
@@ -157,6 +157,11 @@ public class KotlinCompilerClient {
|
|||||||
return connectToService(compilerId, daemonOptions, errStream)
|
return connectToService(compilerId, daemonOptions, errStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun shutdownCompileService(): Unit {
|
||||||
|
KotlinCompilerClient.connectToCompileService(CompilerId(), DaemonLaunchingOptions(), DaemonOptions(), System.out, autostart = false, checkId = false)
|
||||||
|
?.shutdown()
|
||||||
|
}
|
||||||
|
|
||||||
public fun incrementalCompile(compiler: CompileService, args: Array<String>, caches: Map<String, IncrementalCache>, out: OutputStream): Int {
|
public fun incrementalCompile(compiler: CompileService, args: Array<String>, caches: Map<String, IncrementalCache>, out: OutputStream): Int {
|
||||||
|
|
||||||
val outStrm = RemoteOutputStreamServer(out)
|
val outStrm = RemoteOutputStreamServer(out)
|
||||||
@@ -174,6 +179,13 @@ public class KotlinCompilerClient {
|
|||||||
|
|
||||||
public fun isDaemonEnabled(): Boolean = System.getProperty(COMPILE_DAEMON_ENABLED_PROPERTY) != null
|
public fun isDaemonEnabled(): Boolean = System.getProperty(COMPILE_DAEMON_ENABLED_PROPERTY) != null
|
||||||
|
|
||||||
|
public fun configureDaemonLaunchingOptions(opts: DaemonLaunchingOptions) {
|
||||||
|
System.getProperty(COMPILE_DAEMON_JVM_OPTIONS_PROPERTY)?.let {
|
||||||
|
// TODO: find better way to pass and parse jvm options for daemon
|
||||||
|
opts.jvmParams = it.split("##")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class ClientOptions(
|
data class ClientOptions(
|
||||||
public var stop: Boolean = false
|
public var stop: Boolean = false
|
||||||
) :CmdlineParams {
|
) :CmdlineParams {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public val COMPILER_SERVICE_RMI_NAME: String = "KotlinJvmCompilerService"
|
|||||||
public val COMPILER_DAEMON_CLASS_FQN: String = "org.jetbrains.kotlin.rmi.service.CompileDaemon"
|
public val COMPILER_DAEMON_CLASS_FQN: String = "org.jetbrains.kotlin.rmi.service.CompileDaemon"
|
||||||
public val COMPILE_DAEMON_DEFAULT_PORT: Int = 17031
|
public val COMPILE_DAEMON_DEFAULT_PORT: Int = 17031
|
||||||
public val COMPILE_DAEMON_ENABLED_PROPERTY: String ="kotlin.daemon.enabled"
|
public val COMPILE_DAEMON_ENABLED_PROPERTY: String ="kotlin.daemon.enabled"
|
||||||
|
public val COMPILE_DAEMON_JVM_OPTIONS_PROPERTY: String ="kotlin.daemon.jvm.options"
|
||||||
|
|
||||||
|
|
||||||
fun<C, V, P: KProperty1<C,V>> C.propToParams(p: P, conv: ((v: V) -> String) = { it.toString() } ) =
|
fun<C, V, P: KProperty1<C,V>> C.propToParams(p: P, conv: ((v: V) -> String) = { it.toString() } ) =
|
||||||
|
|||||||
@@ -50,5 +50,6 @@
|
|||||||
<orderEntry type="module" module-name="idea-test-framework" scope="TEST" />
|
<orderEntry type="module" module-name="idea-test-framework" scope="TEST" />
|
||||||
<orderEntry type="module" module-name="js.serializer" />
|
<orderEntry type="module" module-name="js.serializer" />
|
||||||
<orderEntry type="module" module-name="idea-js" scope="TEST" />
|
<orderEntry type="module" module-name="idea-js" scope="TEST" />
|
||||||
|
<orderEntry type="module" module-name="kotlinr" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.idea.caches.JarUserDataManager;
|
|||||||
import org.jetbrains.kotlin.idea.debugger.filter.FilterPackage;
|
import org.jetbrains.kotlin.idea.debugger.filter.FilterPackage;
|
||||||
import org.jetbrains.kotlin.idea.decompiler.HasCompiledKotlinInJar;
|
import org.jetbrains.kotlin.idea.decompiler.HasCompiledKotlinInJar;
|
||||||
import org.jetbrains.kotlin.idea.framework.KotlinJavaScriptLibraryDetectionUtil;
|
import org.jetbrains.kotlin.idea.framework.KotlinJavaScriptLibraryDetectionUtil;
|
||||||
|
import org.jetbrains.kotlin.rmi.kotlinr.KotlinCompilerClient;
|
||||||
import org.jetbrains.kotlin.utils.PathUtil;
|
import org.jetbrains.kotlin.utils.PathUtil;
|
||||||
|
|
||||||
public class PluginStartupComponent implements ApplicationComponent {
|
public class PluginStartupComponent implements ApplicationComponent {
|
||||||
@@ -51,5 +52,6 @@ public class PluginStartupComponent implements ApplicationComponent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disposeComponent() {
|
public void disposeComponent() {
|
||||||
|
KotlinCompilerClient.Companion.shutdownCompileService();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.config.CompilerSettings;
|
|||||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
|
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
|
||||||
import org.jetbrains.kotlin.rmi.CompileService;
|
import org.jetbrains.kotlin.rmi.CompileService;
|
||||||
import org.jetbrains.kotlin.rmi.CompilerId;
|
import org.jetbrains.kotlin.rmi.CompilerId;
|
||||||
|
import org.jetbrains.kotlin.rmi.DaemonLaunchingOptions;
|
||||||
import org.jetbrains.kotlin.rmi.DaemonOptions;
|
import org.jetbrains.kotlin.rmi.DaemonOptions;
|
||||||
import org.jetbrains.kotlin.rmi.kotlinr.KotlinCompilerClient;
|
import org.jetbrains.kotlin.rmi.kotlinr.KotlinCompilerClient;
|
||||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||||
@@ -136,8 +137,10 @@ public class KotlinCompilerRunner {
|
|||||||
// the lifetime of JPS process is small anyway, we can neglect the probability of changed compiler
|
// the lifetime of JPS process is small anyway, we can neglect the probability of changed compiler
|
||||||
CompilerId compilerId = CompilerId.makeCompilerId(new File(libPath, "kotlin-compiler.jar"));
|
CompilerId compilerId = CompilerId.makeCompilerId(new File(libPath, "kotlin-compiler.jar"));
|
||||||
DaemonOptions daemonOptions = new DaemonOptions();
|
DaemonOptions daemonOptions = new DaemonOptions();
|
||||||
|
DaemonLaunchingOptions daemonLaunchingOptions = new DaemonLaunchingOptions();
|
||||||
|
KotlinCompilerClient.Companion.configureDaemonLaunchingOptions(daemonLaunchingOptions);
|
||||||
// TODO: find proper stream to report daemon connection progress
|
// TODO: find proper stream to report daemon connection progress
|
||||||
CompileService daemon = KotlinCompilerClient.Companion.connectToCompileService(compilerId, daemonOptions, System.out, true, true);
|
CompileService daemon = KotlinCompilerClient.Companion.connectToCompileService(compilerId, daemonLaunchingOptions, daemonOptions, System.out, true, true);
|
||||||
if (daemon != null) {
|
if (daemon != null) {
|
||||||
Integer res = KotlinCompilerClient.Companion.incrementalCompile(daemon, argsArray, incrementalCaches, out);
|
Integer res = KotlinCompilerClient.Companion.incrementalCompile(daemon, argsArray, incrementalCaches, out);
|
||||||
return res.toString();
|
return res.toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user