@@ -4,8 +4,11 @@ import { Logger, logger } from '../logger';
4
4
import { GradleTasksTreeDataProvider } from '../views' ;
5
5
import { GradleTaskDefinition } from '../tasks' ;
6
6
import { GradleClient } from '../client' ;
7
- import { getRunTaskCommandCancellationKey } from '../client/CancellationKeys' ;
8
7
import { Icons } from '../icons' ;
8
+ import {
9
+ getRunBuildCancellationKey ,
10
+ getRunTaskCommandCancellationKey ,
11
+ } from '../client/CancellationKeys' ;
9
12
10
13
export interface RunTaskOpts {
11
14
projectFolder : string ;
@@ -16,6 +19,14 @@ export interface RunTaskOpts {
16
19
showOutputColors : boolean ;
17
20
}
18
21
22
+ export interface RunBuildOpts {
23
+ projectFolder : string ;
24
+ args : ReadonlyArray < string > ;
25
+ input ?: string ;
26
+ onOutput ?: ( output : Output ) => void ;
27
+ showOutputColors : boolean ;
28
+ }
29
+
19
30
export interface CancelTaskOpts {
20
31
projectFolder : string ;
21
32
taskName : string ;
@@ -29,19 +40,25 @@ export class Api {
29
40
) { }
30
41
31
42
public async runTask ( opts : RunTaskOpts ) : Promise < void > {
43
+ const taskArgs = ( opts . args || [ ] ) . filter ( Boolean ) ;
32
44
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 (
38
55
opts . projectFolder ,
39
- opts . taskName
56
+ opts . args
40
57
) ;
41
58
return this . client . runBuild (
42
59
opts . projectFolder ,
43
60
cancellationKey ,
44
- buildArgs ,
61
+ opts . args ,
45
62
opts . input ,
46
63
0 ,
47
64
task ,
0 commit comments