From 04bd72853619913c27385449170ba33ecccb2ca8 Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Wed, 10 Jan 2024 21:01:35 +0100 Subject: [PATCH] Check for mvn.cmd if mvn fails in build-extension --- src/main/java/com/laytonsmith/core/Main.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/laytonsmith/core/Main.java b/src/main/java/com/laytonsmith/core/Main.java index 9ee8bca06..cced2bcd2 100644 --- a/src/main/java/com/laytonsmith/core/Main.java +++ b/src/main/java/com/laytonsmith/core/Main.java @@ -1537,9 +1537,15 @@ public ArgumentParser getArgumentParser() { @Override @SuppressWarnings("UseSpecificCatch") public void execute(ArgumentParser.ArgumentParserResults parsedArgs) throws Exception { + String mvnCommand = "mvn"; try { new CommandExecutor("git --version").start().waitFor(); - new CommandExecutor("mvn --version").start().waitFor(); + try { + new CommandExecutor("mvn --version").start().waitFor(); + } catch(IOException e) { + new CommandExecutor("mvn.cmd --version").start().waitFor(); + mvnCommand = "mvn.cmd"; + } } catch (IOException e) { System.err.println("Git and Maven are required (and Maven requires the JDK). These three" + " components must be already installed to use this tool."); @@ -1593,7 +1599,7 @@ public void execute(ArgumentParser.ArgumentParserResults parsedArgs) throws Exce .setSystemInputsAndOutputs() .start().waitFor(); System.out.println("Building extension..."); - int mvnBuild = new CommandExecutor(new String[]{"mvn", "package", "-DskipTests"}) + int mvnBuild = new CommandExecutor(new String[]{mvnCommand, "package", "-DskipTests"}) .setSystemInputsAndOutputs() .setWorkingDir(checkoutPath) .start().waitFor();