How to programmatically inject custom values for PORT and HOST parameters in a remote configuration at run configuration creation?

Answered

Hello all,

I've created a custom remote configuration extended the existing one in order to inject my custom values for PORT and HOST parameters.

Just for tests, I tried overriding the "createRemoteConnection()" method, setting HOST and PORT parameters
Please see attached source code files (kotlin code).

Unfortunately, at run configuration (remote) creation , the default HOST and PORT parameters values are displayed instead of mine (that means "localhost" for Host parameter and "5005" for Port parameter)

Does anyone could help me on this issue?

Thanks a lot in advance
Chris

9 comments
Comment actions Permalink

Upload id: 2021_09_07_F9d3o6xjzMExNgJG (files: TeliumRemoteConfiguration.kt, TeliumLauncherConfigurationType.kt)

0
Comment actions Permalink

Can't you modify default values in your extended run config of com.intellij.execution.remote.RemoteConfiguration by setting com.intellij.execution.remote.RemoteConfiguration#HOST/PORT explicitly in constructor?

0
Comment actions Permalink

I explicitly set these parameters via kotlin init block:

init {
initalizeDefaultParameters()
}

private fun initalizeDefaultParameters() {
// TODO I need to inject my default values (read from Gradle build file)
HOST = "1.2.3.4"
PORT = "1234"
}

I was not working as expected using a previous project (strange behaviour).

I created a new project, once creating a new custom "Remote configuration" it works now.

Thanks a lot Yann.

0
Comment actions Permalink

I think I found the issue with parameters injection.

Once a first remote configuration has been created, it creates a template which is used for next remote configuration creation.

Is there a way to force the remote configuration creation without using the template?

I want to be sure each time I create a new remote configuration that my new parameters are taken into account.

0
Comment actions Permalink

Does com.intellij.execution.configurations.ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project) help?

0
Comment actions Permalink

I just figured out that it was linked to template configuration just created (before seeing your message).

It confirms my doubts, so yes I think createTemplateConfiguration could help.

Thanks a lot Yann.

0
Comment actions Permalink

Using com.intellij.execution.configurations.ConfigurationFactory#createTemplateConfiguration(com.intellij.openapi.project.Project), seems not updating the already created template configuration.

I need a kind of com.intellij.execution.configurations.ConfigurationFactory#updateTemplateConfiguration, or removing the existing one before re-creating it.

0
Comment actions Permalink

In other words, I need a dynamic remote configuration creation...

0
Comment actions Permalink

I finally found the solution, as simple as it is. Sorry I'm just starting using Intellij...

In fact, I just have to override the com.ingenico.intellij.launch.configurations.TeliumLauncherConfigurationType#createConfiguration

It does the trick.

Thanks again Yann for your support.

0

Please sign in to leave a comment.