@@ -15,6 +15,9 @@ public class BuildProject {
1515
1616 private static final String LIB_DEPS_DOWNLOAD_DIR = "_libdeps" ;
1717
18+ private static final String MAVEN_CMD = System .getProperty ("os.name" ).contains ("win" ) ? "mvn.cmd" : "mvn" ;
19+ private static final String GRADLE_CMD = System .getProperty ("os.name" ).contains ("win" ) ? "gradlew.bat" : "gradlew" ;
20+
1821 private static boolean buildWithTool (String [] buildCommand ) {
1922 Log .info ("Building the project using " + buildCommand [0 ] + "." );
2023 ProcessBuilder processBuilder = new ProcessBuilder (buildCommand );
@@ -41,7 +44,7 @@ private static boolean buildWithTool(String[] buildCommand) {
4144 * @return true if Maven is installed, false otherwise.
4245 */
4346 private static boolean isMavenInstalled () {
44- ProcessBuilder processBuilder = new ProcessBuilder ("mvn" , "--version" );
47+ ProcessBuilder processBuilder = new ProcessBuilder (MAVEN_CMD , "--version" );
4548 try {
4649 Process process = processBuilder .start ();
4750 BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
@@ -70,7 +73,7 @@ private static boolean mavenBuild(String projectPath) {
7073 return false ;
7174 }
7275 String [] mavenCommand = {
73- "mvn" , "clean" , "package" , "-f" , projectPath + "/pom.xml" , "-B" , "-V" , "-e" , "-Drat.skip" ,
76+ MAVEN_CMD , "clean" , "package" , "-f" , projectPath + "/pom.xml" , "-B" , "-V" , "-e" , "-Drat.skip" ,
7477 "-Dfindbugs.skip" , "-Dcheckstyle.skip" , "-Dpmd.skip=true" , "-Dspotbugs.skip" , "-Denforcer.skip" ,
7578 "-Dmaven.javadoc.skip" , "-DskipTests" , "-Dmaven.test.skip.exec" , "-Dlicense.skip=true" ,
7679 "-Drat.skip=true" , "-Dspotless.check.skip=true" };
@@ -80,7 +83,7 @@ private static boolean mavenBuild(String projectPath) {
8083
8184 public static boolean gradleBuild (String projectPath ) {
8285 // Adjust Gradle command as needed
83- String gradleWrapper = projectPath + "/gradlew" ;
86+ String gradleWrapper = projectPath + File . separator + GRADLE_CMD ;
8487 String [] gradleCommand = { gradleWrapper , "clean" , "compileJava" , "-p" , projectPath };
8588 return buildWithTool (gradleCommand );
8689 }
@@ -100,7 +103,7 @@ private static boolean buildProject(String projectPath, String build) {
100103 }
101104 else {
102105 // Update command with a project path
103- build = build .replace ("mvn" , "mvn -f " + projectPath );
106+ build = build .replace (MAVEN_CMD , MAVEN_CMD + " -f " + projectPath );
104107 Log .info ("Using custom build command: " + build );
105108 String [] customBuildCommand = build .split (" " );
106109 return buildWithTool (customBuildCommand );
@@ -139,7 +142,7 @@ public static boolean downloadLibraryDependencies(String projectPath) {
139142 if (pomFile .exists ()) {
140143 Log .info ("Found pom.xml in the project directory. Using Maven to download dependencies." );
141144 String [] mavenCommand = {
142- "mvn" , "--no-transfer-progress" , "-f" ,
145+ MAVEN_CMD , "--no-transfer-progress" , "-f" ,
143146 Paths .get (projectPath , "pom.xml" ).toString (),
144147 "dependency:copy-dependencies" ,
145148 "-DoutputDirectory=" + libDownloadPath .toString ()
0 commit comments