Skip to content

Commit

Permalink
fix: Connect Quarkus run configuration with Services view support
Browse files Browse the repository at this point in the history
Fixes #1265

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Nov 20, 2023
1 parent 653fb62 commit cc3b946
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
******************************************************************************/
package com.redhat.devtools.intellij.quarkus.run;

import com.intellij.execution.DefaultExecutionTarget;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionManager;
import com.intellij.execution.ExecutionTarget;
import com.intellij.execution.Executor;
import com.intellij.execution.RunManager;
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.execution.*;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ModuleBasedConfiguration;
import com.intellij.execution.configurations.RunConfiguration;
Expand Down Expand Up @@ -133,12 +127,13 @@ public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEn
telemetry.property("kind", executor.getId());
BuildToolDelegate toolDelegate = BuildToolDelegate.getDelegate(getModule());
allocateLocalPort();
RunProfileState state = null;
if (toolDelegate != null) {
telemetry.property("tool", toolDelegate.getDisplay());
RunnerAndConfigurationSettings settings = toolDelegate.getConfigurationDelegate(getModule(), this);
if (settings != null) {
long groupId = ExecutionEnvironment.getNextUnusedExecutionId();
doRunConfiguration(settings, executor, DefaultExecutionTarget.INSTANCE, groupId, null,
state = doRunConfiguration(settings, executor, DefaultExecutionTarget.INSTANCE, groupId, null,
desc -> desc.getComponent().putClientProperty(QuarkusConstants.QUARKUS_RUN_CONTEXT_KEY, new QuarkusRunContext(getModule())));
}
} else {
Expand All @@ -153,7 +148,7 @@ public void run(@NotNull ProgressIndicator indicator) {
}
});
}
return null;
return state;
}

private void waitForPortAvailable(int port, ProgressIndicator monitor) throws IOException {
Expand Down Expand Up @@ -212,15 +207,15 @@ public int getPort() {
return port;
}

private static void doRunConfiguration(@NotNull RunnerAndConfigurationSettings configuration,
@NotNull Executor executor,
@Nullable ExecutionTarget targetOrNullForDefault,
@Nullable Long executionId,
@Nullable DataContext dataContext,
ProgramRunner.Callback callback) {
private static RunProfileState doRunConfiguration(@NotNull RunnerAndConfigurationSettings configuration,
@NotNull Executor executor,
@Nullable ExecutionTarget targetOrNullForDefault,
@Nullable Long executionId,
@Nullable DataContext dataContext,
ProgramRunner.Callback callback) throws ExecutionException {
ExecutionEnvironmentBuilder builder = createEnvironment(executor, configuration);
if (builder == null) {
return;
return null;
}

if (targetOrNullForDefault != null) {
Expand All @@ -235,7 +230,8 @@ private static void doRunConfiguration(@NotNull RunnerAndConfigurationSettings c
if (dataContext != null) {
builder.dataContext(dataContext);
}
ExecutionManager.getInstance(configuration.getConfiguration().getProject()).restartRunProfile(builder.build(callback));

return configuration.getConfiguration().getState(executor, builder.build(callback));
}

}

0 comments on commit cc3b946

Please sign in to comment.