12
12
import java .util .List ;
13
13
import java .util .Set ;
14
14
import java .util .stream .Collectors ;
15
+ import java .util .Arrays ;
15
16
16
17
interface BazelClient {
17
18
List <BazelTarget > queryAllTargets () throws IOException ;
@@ -23,10 +24,14 @@ interface BazelClient {
23
24
class BazelClientImpl implements BazelClient {
24
25
private Path workingDirectory ;
25
26
private Path bazelPath ;
27
+ private List <String > startupOptions ;
28
+ private List <String > commandOptions ;
26
29
27
- BazelClientImpl (Path workingDirectory , Path bazelPath ) {
30
+ BazelClientImpl (Path workingDirectory , Path bazelPath , String startupOptions , String commandOptions ) {
28
31
this .workingDirectory = workingDirectory .normalize ();
29
32
this .bazelPath = bazelPath ;
33
+ this .startupOptions = startupOptions != null ? Arrays .asList (startupOptions .split (" " )): new ArrayList <String >();
34
+ this .commandOptions = commandOptions != null ? Arrays .asList (commandOptions .split (" " )): new ArrayList <String >();
30
35
}
31
36
32
37
@ Override
@@ -94,15 +99,20 @@ public Set<BazelSourceFileTarget> convertFilepathsToSourceTargets(Set<Path> file
94
99
}
95
100
96
101
private List <Build .Target > performBazelQuery (String query ) throws IOException {
97
- ProcessBuilder pb = new ProcessBuilder (bazelPath .toString (),
98
- "query" ,
99
- query ,
100
- "--output" ,
101
- "streamed_proto" ,
102
- "--order_output=no" ,
103
- "--show_progress=false" ,
104
- "--show_loading_progress=false"
105
- ).directory (workingDirectory .toFile ());
102
+ List <String > cmd = new ArrayList <String >();
103
+
104
+ cmd .add ((bazelPath .toString ()));
105
+ cmd .addAll (this .startupOptions );
106
+ cmd .add ("query" );
107
+ cmd .add ("--output" );
108
+ cmd .add ("streamed_proto" );
109
+ cmd .add ("--order_output=no" );
110
+ cmd .add ("--show_progress=false" );
111
+ cmd .add ("--show_loading_progress=false" );
112
+ cmd .addAll (this .commandOptions );
113
+ cmd .add (query );
114
+
115
+ ProcessBuilder pb = new ProcessBuilder (cmd ).directory (workingDirectory .toFile ());
106
116
Process process = pb .start ();
107
117
ArrayList <Build .Target > targets = new ArrayList <>();
108
118
while (true ) {
0 commit comments