1212import java .util .List ;
1313import java .util .Set ;
1414import java .util .stream .Collectors ;
15+ import java .util .Arrays ;
1516
1617interface BazelClient {
1718 List <BazelTarget > queryAllTargets () throws IOException ;
@@ -23,10 +24,14 @@ interface BazelClient {
2324class BazelClientImpl implements BazelClient {
2425 private Path workingDirectory ;
2526 private Path bazelPath ;
27+ private List <String > startupOptions ;
28+ private List <String > commandOptions ;
2629
27- BazelClientImpl (Path workingDirectory , Path bazelPath ) {
30+ BazelClientImpl (Path workingDirectory , Path bazelPath , String startupOptions , String commandOptions ) {
2831 this .workingDirectory = workingDirectory .normalize ();
2932 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 >();
3035 }
3136
3237 @ Override
@@ -94,15 +99,20 @@ public Set<BazelSourceFileTarget> convertFilepathsToSourceTargets(Set<Path> file
9499 }
95100
96101 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 ());
106116 Process process = pb .start ();
107117 ArrayList <Build .Target > targets = new ArrayList <>();
108118 while (true ) {
0 commit comments