diff --git a/README.md b/README.md index cd89474..a33df48 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,15 @@ can be displayed live in a window. Each build is launched inside the repository folder. In order to determine if the build is a success or not, the application checks the result of the mvn command. +## Configuration + +In the **Tools** menu and then **Configuration**, you can define the configuration of the software. You will need to +enter the full path of the **mvn** command. +You will also be able to define custom maven options. For example if you often use an option like **-DskipTests=true** +and you don't want to enter this option each time you add/edit a repository, you can define it here. Then when adding/editing +a repository you will get it in the help window of the maven options. + + ## Workspaces A workspace allows you to have multiple repositories available in ***CompilerFX***, grouped @@ -39,7 +48,8 @@ is executed before ***install***. Custom goals will be available in a next versi ## Maven options -Maven option can be added when adding/editing a repository using the **Options** field. +Maven option can be added when adding/editing a repository using the **Options** field. Using the help button, maven options +are listed, default ones as well as custom ones. Double clicking on an option will add it automatically to the field. ## Post build commands diff --git a/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java b/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java index 8c5e24c..878ef1b 100644 --- a/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java +++ b/src/main/java/com/twasyl/compilerfx/app/CompilerFXApp.java @@ -22,7 +22,7 @@ public class CompilerFXApp extends Application { - public static String version = "0.3.0"; + public static String version = "0.3.1"; private static final ReadOnlyObjectProperty current = new SimpleObjectProperty<>(); private final ReadOnlyObjectProperty currentStage = new SimpleObjectProperty<>(); diff --git a/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java b/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java index afa6f25..9a3c0d6 100644 --- a/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java +++ b/src/main/java/com/twasyl/compilerfx/controllers/CompilerFXController.java @@ -82,6 +82,10 @@ public class CompilerFXController implements Initializable { @FXML private void showAbout(ActionEvent event) { final StringBuilder changeLog = new StringBuilder(); changeLog.append("Change logs:\n\n"); + changeLog.append("version 0.3.1:\n\n"); + changeLog.append(" - Fix commands execution on Windows platforms\n"); + changeLog.append(" - Edit button in edition screen for a repository is renamed to Save"); + changeLog.append("\n\n"); changeLog.append("version 0.3.0:\n\n"); changeLog.append(" - Abort feature for the current workspace and for all\n"); changeLog.append(" - Feature for creating custom maven options\n"); diff --git a/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java b/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java index 98f116b..21b8a7d 100644 --- a/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java +++ b/src/main/java/com/twasyl/compilerfx/utils/MavenExecutor.java @@ -10,6 +10,7 @@ import javafx.collections.ObservableList; import java.io.*; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -22,7 +23,10 @@ public class MavenExecutor { public static List getMavenOptions() { - final String[] command = new String[] {Configuration.getInstance().getMavenCommand(), "--help"}; + + final String[] command = OSUtils.isWindows() ? + new String[] {"cmd.exe", "/C", Configuration.getInstance().getMavenCommand(), "--help"} : + new String[] {Configuration.getInstance().getMavenCommand(), "--help"}; final List options = new ArrayList<>(); for(MavenRepository.MavenOption option : Configuration.getInstance().getCustomMavenOptions()) { @@ -35,7 +39,6 @@ public static List getMavenOptions() { try { final Process process = builder.start(); - process.waitFor(); reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; @@ -80,7 +83,6 @@ public static List getMavenOptions() { } } } catch (IOException e) { - } catch (InterruptedException e) { } finally { if(reader != null) { try { @@ -139,6 +141,7 @@ public void run() { Process process = null; File repositoryDirectory = null; + final boolean isWindows = OSUtils.isWindows(); for (final MavenRepository repository : repositories) { @@ -154,6 +157,11 @@ public void run() { Configuration.getInstance().currentBuildsProperty().add(repository); command.clear(); + if(isWindows) { + command.add("cmd.exe"); + command.add("/C"); + } + command.add(Configuration.getInstance().getMavenCommand()); if(repository.getOptions() != null && !repository.getOptions().trim().isEmpty()) { @@ -255,8 +263,9 @@ public static void executePostBuildCommands(final ObservableList command = new ArrayList<>(); Process process = null; File repositoryDirectory = null; @@ -284,7 +293,15 @@ public void run() { while (groupIndex <= matcher.groupCount()) { processBuilder.directory(new File(repository.getPath())); - processBuilder.command(Arrays.asList(matcher.group(groupIndex).split(" "))); + command.clear(); + + if(isWindows) { + command.add("cmd.exe"); + command.add("/C"); + } + + command.addAll(Arrays.asList(matcher.group(groupIndex).split(" "))); + processBuilder.command(command); process = processBuilder.start(); repository.setActiveProcess(process); @@ -363,7 +380,6 @@ public void run() { try { while((line = in.readLine()) != null) { - try { repository.setLastExecutionStack( (repository.getLastExecutionStack() == null ? "" : repository.getLastExecutionStack()) diff --git a/src/main/java/com/twasyl/compilerfx/utils/OSUtils.java b/src/main/java/com/twasyl/compilerfx/utils/OSUtils.java new file mode 100644 index 0000000..9ea22db --- /dev/null +++ b/src/main/java/com/twasyl/compilerfx/utils/OSUtils.java @@ -0,0 +1,35 @@ +package com.twasyl.compilerfx.utils; + +public class OSUtils { + private static String OS = System.getProperty("os.name").toLowerCase(); + + public enum OperatingSystem { + WINDOWS, UNIX, MAC + } + + public static boolean isWindows() { + return (OS.indexOf("win") >= 0); + } + + public static boolean isMac() { + return (OS.indexOf("mac") >= 0); + } + + public static boolean isUnix() { + return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0); + } + + public static OperatingSystem getOperatingSystem() { + OperatingSystem os = null; + + if (isWindows()) { + os = OperatingSystem.WINDOWS; + } else if(isUnix()) { + os = OperatingSystem.UNIX; + } else if(isMac()) { + os = OperatingSystem.MAC; + } + + return os; + } +} diff --git a/src/main/resources/com/twasyl/compilerfx/fxml/EditRepository.fxml b/src/main/resources/com/twasyl/compilerfx/fxml/EditRepository.fxml index c345759..3068a9e 100644 --- a/src/main/resources/com/twasyl/compilerfx/fxml/EditRepository.fxml +++ b/src/main/resources/com/twasyl/compilerfx/fxml/EditRepository.fxml @@ -53,7 +53,7 @@