Skip to content

Commit 28f3b29

Browse files
committed
Expose runBuild public API
1 parent 06f26fa commit 28f3b29

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

extension/src/api/Api.ts

+25-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { Logger, logger } from '../logger';
44
import { GradleTasksTreeDataProvider } from '../views';
55
import { GradleTaskDefinition } from '../tasks';
66
import { GradleClient } from '../client';
7-
import { getRunTaskCommandCancellationKey } from '../client/CancellationKeys';
87
import { Icons } from '../icons';
8+
import {
9+
getRunBuildCancellationKey,
10+
getRunTaskCommandCancellationKey,
11+
} from '../client/CancellationKeys';
912

1013
export interface RunTaskOpts {
1114
projectFolder: string;
@@ -16,6 +19,14 @@ export interface RunTaskOpts {
1619
showOutputColors: boolean;
1720
}
1821

22+
export interface RunBuildOpts {
23+
projectFolder: string;
24+
args: ReadonlyArray<string>;
25+
input?: string;
26+
onOutput?: (output: Output) => void;
27+
showOutputColors: boolean;
28+
}
29+
1930
export interface CancelTaskOpts {
2031
projectFolder: string;
2132
taskName: string;
@@ -29,19 +40,25 @@ export class Api {
2940
) {}
3041

3142
public async runTask(opts: RunTaskOpts): Promise<void> {
43+
const taskArgs = (opts.args || []).filter(Boolean);
3244
const task = await this.findTask(opts.projectFolder, opts.taskName);
33-
const definition = task.definition as GradleTaskDefinition;
34-
const buildArgs = [definition.script]
35-
.concat(opts.args || [])
36-
.filter(Boolean);
37-
const cancellationKey = getRunTaskCommandCancellationKey(
45+
const runBuildArgs = [opts.taskName].concat(taskArgs);
46+
const runBuildOpts = {
47+
...opts,
48+
args: runBuildArgs,
49+
};
50+
return this.runBuild(runBuildOpts, task);
51+
}
52+
53+
public async runBuild(opts: RunBuildOpts, task?: vscode.Task): Promise<void> {
54+
const cancellationKey = getRunBuildCancellationKey(
3855
opts.projectFolder,
39-
opts.taskName
56+
opts.args
4057
);
4158
return this.client.runBuild(
4259
opts.projectFolder,
4360
cancellationKey,
44-
buildArgs,
61+
opts.args,
4562
opts.input,
4663
0,
4764
task,

0 commit comments

Comments
 (0)