44
55import java .nio .file .Path ;
66import java .nio .file .Paths ;
7- import java .util .ArrayList ;
8- import java .util .Arrays ;
9- import java .util .Collections ;
10- import java .util .List ;
11- import java .util .Map ;
7+ import java .util .*;
128
139/**
1410 * Represents a Gauge command and provides methods to construct command-line arguments for Gauge execution.
@@ -37,16 +33,13 @@ public GaugeCommand(final GaugeExtension extension, final Project project) {
3733 * @return the path to the Gauge executable
3834 */
3935 public String getExecutable () {
40- final String binary = "gauge" ;
4136 return project .hasProperty (GaugeProperty .GAUGE_ROOT .getKey ())
42- ? getExecutablePath (properties .get (GaugeProperty .GAUGE_ROOT .getKey ()).toString ()).toString ()
43- : extension .getGaugeRoot ().isPresent ()
44- ? getExecutablePath (extension .getGaugeRoot ().get ()).toString ()
45- : binary ;
37+ ? getExecutablePath (properties .get (GaugeProperty .GAUGE_ROOT .getKey ()).toString ())
38+ : extension .getGaugeRoot ().map (this ::getExecutablePath ).getOrElse ("gauge" );
4639 }
4740
48- private Path getExecutablePath (final String gaugeRoot ) {
49- return Paths .get (gaugeRoot , "bin" , "gauge" );
41+ private String getExecutablePath (final String gaugeRoot ) {
42+ return Paths .get (gaugeRoot , "bin" , "gauge" ). toString () ;
5043 }
5144
5245 /**
@@ -105,33 +98,33 @@ public List<Object> getFlags() {
10598 flags .add (GaugeProperty .IN_PARALLEL .getFlag ());
10699 final int nodes = getNodes ();
107100 if (nodes != 0 ) {
108- flags .addAll (List .of (GaugeProperty .NODES .getFlag (), nodes ));
101+ flags .add (GaugeProperty .NODES .getFlag ());
102+ flags .add (nodes );
109103 }
110104 }
111105 return flags ;
112106 }
113107
114108 private List <String > getAdditionalFlags () {
115- return project .hasProperty (GaugeProperty .ADDITIONAL_FLAGS .getKey ())
116- ? getListFromString (properties .get (GaugeProperty .ADDITIONAL_FLAGS .getKey ()).toString ())
117- : extension .getAdditionalFlags ().isPresent ()
118- ? getListFromString (extension .getAdditionalFlags ().get ())
119- : Collections .emptyList ();
109+ return getListFromString (project .hasProperty (GaugeProperty .ADDITIONAL_FLAGS .getKey ())
110+ ? properties .get (GaugeProperty .ADDITIONAL_FLAGS .getKey ()).toString ()
111+ : extension .getAdditionalFlags ().getOrElse ("" )
112+ );
120113 }
121114
122115 private List <String > getListFromString (final String value ) {
123- return Arrays .stream (value .split ("\\ s+" )).map (String ::trim ).toList ();
116+ return Arrays .stream (value .split ("\\ s+" )).map (String ::trim ).filter ( s -> ! s . isEmpty ()). toList ();
124117 }
125118
126119 private int getNodes () {
127120 return project .hasProperty (GaugeProperty .NODES .getKey ())
128121 ? Integer .parseInt (properties .get (GaugeProperty .NODES .getKey ()).toString ())
129- : extension .getNodes ().isPresent () ? extension . getNodes (). get () : 0 ;
122+ : extension .getNodes ().getOrElse ( 0 ) ;
130123 }
131124
132125 private boolean isInParallel () {
133126 return project .hasProperty (GaugeProperty .IN_PARALLEL .getKey ())
134- ? Boolean .parseBoolean (project . getProperties () .get (GaugeProperty .IN_PARALLEL .getKey ()).toString ())
127+ ? Boolean .parseBoolean (properties .get (GaugeProperty .IN_PARALLEL .getKey ()).toString ())
135128 : extension .getInParallel ().get ();
136129 }
137130
@@ -154,7 +147,7 @@ public List<String> getSpecsDir() {
154147 public List <String > getTags () {
155148 final String tags = project .hasProperty (GaugeProperty .TAGS .getKey ())
156149 ? properties .get (GaugeProperty .TAGS .getKey ()).toString ()
157- : extension .getTags ().isPresent () ? extension . getTags (). get () : "" ;
150+ : extension .getTags ().getOrElse ( "" ) ;
158151 return !tags .isEmpty () ? List .of (GaugeProperty .TAGS .getFlag (), tags ) : Collections .emptyList ();
159152 }
160153
0 commit comments