|
1 | 1 | // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
2 | 2 | package com.redhat.devtools.intellij.quarkus.buildtool.gradle;
|
3 | 3 |
|
4 |
| -import com.intellij.build.BuildView; |
5 | 4 | import com.intellij.execution.ExecutionException;
|
6 |
| -import com.intellij.execution.ExecutionManager; |
7 |
| -import com.intellij.execution.ExecutionResult; |
8 | 5 | import com.intellij.execution.configurations.RunProfile;
|
9 |
| -import com.intellij.execution.configurations.RunProfileState; |
10 | 6 | import com.intellij.execution.configurations.RunnerSettings;
|
11 | 7 | import com.intellij.execution.runners.ExecutionEnvironment;
|
12 | 8 | import com.intellij.execution.runners.ProgramRunner;
|
13 |
| -import com.intellij.execution.runners.RunContentBuilder; |
14 |
| -import com.intellij.execution.testframework.HistoryTestRunnableState; |
15 |
| -import com.intellij.execution.ui.RunContentDescriptor; |
16 |
| -import com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunnableState; |
| 9 | +import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; |
17 | 10 | import com.redhat.devtools.intellij.quarkus.buildtool.BuildToolDelegate;
|
18 | 11 | import com.redhat.devtools.intellij.quarkus.buildtool.maven.MavenToolDelegate;
|
19 | 12 | import com.redhat.devtools.intellij.quarkus.run.QuarkusRunConfiguration;
|
20 |
| -import org.jetbrains.concurrency.Promises; |
21 | 13 |
|
22 | 14 | /**
|
23 | 15 | * Program runner to run/debug a Gradle configuration.
|
@@ -54,59 +46,7 @@ public boolean canRun(String executorId, RunProfile profile) {
|
54 | 46 |
|
55 | 47 | @Override
|
56 | 48 | public void execute(ExecutionEnvironment environment) throws ExecutionException {
|
57 |
| - RunProfileState state = environment.getState(); |
58 |
| - if (state == null) { |
59 |
| - return; |
60 |
| - } |
61 |
| - ExecutionManager.getInstance(environment.getProject()).startRunProfile(environment, () -> { |
62 |
| - try { |
63 |
| - return Promises.resolvedPromise(doExecute(state, environment)); |
64 |
| - } catch (ExecutionException e) { |
65 |
| - throw new RuntimeException(e); |
66 |
| - } |
67 |
| - }); |
68 |
| - } |
69 |
| - |
70 |
| - private RunContentDescriptor doExecute(RunProfileState state, ExecutionEnvironment environment) throws ExecutionException { |
71 |
| - if (!(state instanceof ExternalSystemRunnableState) && !(state instanceof HistoryTestRunnableState)) { |
72 |
| - return null; |
73 |
| - } |
74 |
| - |
75 |
| - RunContentDescriptor runContentDescriptor; |
76 |
| - ExecutionResult executionResult = state.execute(environment.getExecutor(), this); |
77 |
| - if (executionResult == null) { |
78 |
| - return null; |
79 |
| - } |
80 |
| - runContentDescriptor = new RunContentBuilder(executionResult, environment).showRunContent(environment.getContentToReuse()); |
81 |
| - if (runContentDescriptor == null) { |
82 |
| - return null; |
83 |
| - } |
84 |
| - |
85 |
| - if (state instanceof HistoryTestRunnableState) { |
86 |
| - return runContentDescriptor; |
87 |
| - } |
88 |
| - |
89 |
| - ((ExternalSystemRunnableState) state).setContentDescriptor(runContentDescriptor); |
90 |
| - |
91 |
| - if (executionResult.getExecutionConsole() instanceof BuildView) { |
92 |
| - return runContentDescriptor; |
93 |
| - } |
94 |
| - |
95 |
| - RunContentDescriptor descriptor = new RunContentDescriptor( |
96 |
| - runContentDescriptor.getExecutionConsole(), |
97 |
| - runContentDescriptor.getProcessHandler(), |
98 |
| - runContentDescriptor.getComponent(), |
99 |
| - runContentDescriptor.getDisplayName(), |
100 |
| - runContentDescriptor.getIcon(), |
101 |
| - null, |
102 |
| - runContentDescriptor.getRestartActions() |
103 |
| - ) { |
104 |
| - @Override |
105 |
| - public boolean isHiddenContent() { |
106 |
| - return true; |
107 |
| - } |
108 |
| - }; |
109 |
| - descriptor.setRunnerLayoutUi(runContentDescriptor.getRunnerLayoutUi()); |
110 |
| - return descriptor; |
| 49 | + // Execute environment with the 'ExternalSystemTaskRunner.RUNNER_ID' |
| 50 | + ProgramRunner.findRunnerById(ExternalSystemConstants.RUNNER_ID).execute(environment); |
111 | 51 | }
|
112 | 52 | }
|
0 commit comments