@@ -4,7 +4,10 @@ import { 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' ;
7
+ import {
8
+ getRunBuildCancellationKey ,
9
+ getRunTaskCommandCancellationKey ,
10
+ } from '../client/CancellationKeys' ;
8
11
9
12
export interface RunTaskOpts {
10
13
projectFolder : string ;
@@ -15,6 +18,14 @@ export interface RunTaskOpts {
15
18
showOutputColors : boolean ;
16
19
}
17
20
21
+ export interface RunBuildOpts {
22
+ projectFolder : string ;
23
+ args : ReadonlyArray < string > ;
24
+ input ?: string ;
25
+ onOutput ?: ( output : Output ) => void ;
26
+ showOutputColors : boolean ;
27
+ }
28
+
18
29
export interface CancelTaskOpts {
19
30
projectFolder : string ;
20
31
taskName : string ;
@@ -30,19 +41,25 @@ export class Api {
30
41
) { }
31
42
32
43
public async runTask ( opts : RunTaskOpts ) : Promise < void > {
44
+ const taskArgs = ( opts . args || [ ] ) . filter ( Boolean ) ;
33
45
const task = await this . findTask ( opts . projectFolder , opts . taskName ) ;
34
- const definition = task . definition as GradleTaskDefinition ;
35
- const buildArgs = [ definition . script ]
36
- . concat ( opts . args || [ ] )
37
- . filter ( Boolean ) ;
38
- const cancellationKey = getRunTaskCommandCancellationKey (
46
+ const runBuildArgs = [ opts . taskName ] . concat ( taskArgs ) ;
47
+ const runBuildOpts = {
48
+ ...opts ,
49
+ args : runBuildArgs ,
50
+ } ;
51
+ return this . runBuild ( runBuildOpts , task ) ;
52
+ }
53
+
54
+ public async runBuild ( opts : RunBuildOpts , task ?: vscode . Task ) : Promise < void > {
55
+ const cancellationKey = getRunBuildCancellationKey (
39
56
opts . projectFolder ,
40
- opts . taskName
57
+ opts . args
41
58
) ;
42
59
return this . client . runBuild (
43
60
opts . projectFolder ,
44
61
cancellationKey ,
45
- buildArgs ,
62
+ opts . args ,
46
63
opts . input ,
47
64
0 ,
48
65
task ,
0 commit comments