9
9
import java .nio .file .Paths ;
10
10
import java .text .MessageFormat ;
11
11
import java .util .*;
12
+ import java .util .function .Predicate ;
12
13
import java .util .stream .Stream ;
13
14
14
15
@@ -29,7 +30,7 @@ public class BuildProject {
29
30
* @return the maven command
30
31
*/
31
32
public static String getMavenCommand () {
32
- String mvnSystemCommand = Arrays .stream (System .getenv ("PATH" ).split (System . getProperty ( "path.separator" ) )).filter (Predicate .not (String ::isBlank )).filter (Predicate .not (String ::isEmpty )).map (path -> new File (path , System .getProperty ("os.name" ).toLowerCase ().contains ("windows" ) ? "mvn.cmd" : "mvn" )).filter (File ::exists ).findFirst ().map (File ::getAbsolutePath ).orElse (null );
33
+ String mvnSystemCommand = Arrays .stream (System .getenv ("PATH" ).split (File . pathSeparator )).filter (Predicate .not (String ::isBlank )).filter (Predicate .not (String ::isEmpty )).map (path -> new File (path , System .getProperty ("os.name" ).toLowerCase ().contains ("windows" ) ? "mvn.cmd" : "mvn" )).filter (File ::exists ).findFirst ().map (File ::getAbsolutePath ).orElse (null );
33
34
File mvnWrapper = System .getProperty ("os.name" ).toLowerCase ().contains ("windows" ) ? new File (projectRootPom , "mvnw.cmd" ) : new File (projectRootPom , "mvnw" );
34
35
return commandExists (mvnWrapper .getAbsoluteFile ()).getKey () ? mvnWrapper .getAbsoluteFile ().toString () : mvnSystemCommand ;
35
36
}
@@ -40,7 +41,7 @@ public static String getMavenCommand() {
40
41
* @return the gradle command
41
42
*/
42
43
public static String getGradleCommand () {
43
- String gradleSystemCommand = Arrays .stream (System .getenv ("PATH" ).split (System . getProperty ( "path.separator" ) )).filter (Predicate .not (String ::isBlank )).filter (Predicate .not (String ::isEmpty )).map (path -> new File (path , System .getProperty ("os.name" ).toLowerCase ().contains ("windows" ) ? "gradle.bat" : "gradle" )).filter (File ::exists ).findFirst ().map (File ::getAbsolutePath ).orElse (null );
44
+ String gradleSystemCommand = Arrays .stream (System .getenv ("PATH" ).split (File . pathSeparator )).filter (Predicate .not (String ::isBlank )).filter (Predicate .not (String ::isEmpty )).map (path -> new File (path , System .getProperty ("os.name" ).toLowerCase ().contains ("windows" ) ? "gradle.bat" : "gradle" )).filter (File ::exists ).findFirst ().map (File ::getAbsolutePath ).orElse (null );
44
45
File gradleWrapper = System .getProperty ("os.name" ).toLowerCase ().contains ("windows" ) ? new File (projectRootPom , "gradlew.bat" ) : new File (projectRootPom , "gradlew" );
45
46
46
47
return commandExists (gradleWrapper .getAbsoluteFile ()).getKey () ? gradleWrapper .getAbsoluteFile () .toString () : gradleSystemCommand ;
0 commit comments