@Test public void configure_maven_home_on_linux() throws Exception { emulateLinux(); File home = temp.newFolder(); Configuration configuration = Configuration.builder().setProperty("MAVEN_HOME", home.getCanonicalPath()).build(); String result = underTest.buildMvnPath(configuration); assertThat(result).isEqualTo(new File(home, "bin/mvn").getCanonicalPath()); }
String buildMvnPath(Configuration config) throws IOException { Optional<String> binary = Optional.ofNullable(config.getStringByKeys("maven.binary", "MAVEN_BINARY")); File home = config.fileSystem().mavenHome(); if (home == null) { return binary.orElse(os.isWindows() ? "mvn.cmd" : "mvn"); } if (binary.isPresent()) { return new File(home, "bin/" + binary.get()).getCanonicalPath(); } if (os.isWindows()) { File bin = new File(home, "bin/mvn.bat"); if (bin.exists()) { return bin.getCanonicalPath(); } return new File(home, "bin/mvn.cmd").getCanonicalPath(); } return new File(home, "bin/mvn").getCanonicalPath(); }
MavenBuildExecutor extends AbstractBuildExecutor<MavenBuild> { String buildMvnPath(Configuration config) throws IOException { Optional<String> binary = Optional.ofNullable(config.getStringByKeys("maven.binary", "MAVEN_BINARY")); File home = config.fileSystem().mavenHome(); if (home == null) { return binary.orElse(os.isWindows() ? "mvn.cmd" : "mvn"); } if (binary.isPresent()) { return new File(home, "bin/" + binary.get()).getCanonicalPath(); } if (os.isWindows()) { File bin = new File(home, "bin/mvn.bat"); if (bin.exists()) { return bin.getCanonicalPath(); } return new File(home, "bin/mvn.cmd").getCanonicalPath(); } return new File(home, "bin/mvn").getCanonicalPath(); } }
MavenBuildExecutor extends AbstractBuildExecutor<MavenBuild> { String buildMvnPath(Configuration config) throws IOException { Optional<String> binary = Optional.ofNullable(config.getStringByKeys("maven.binary", "MAVEN_BINARY")); File home = config.fileSystem().mavenHome(); if (home == null) { return binary.orElse(os.isWindows() ? "mvn.cmd" : "mvn"); } if (binary.isPresent()) { return new File(home, "bin/" + binary.get()).getCanonicalPath(); } if (os.isWindows()) { File bin = new File(home, "bin/mvn.bat"); if (bin.exists()) { return bin.getCanonicalPath(); } return new File(home, "bin/mvn.cmd").getCanonicalPath(); } return new File(home, "bin/mvn").getCanonicalPath(); } MavenBuildExecutor(Os os);  MavenBuildExecutor(); }
MavenBuildExecutor extends AbstractBuildExecutor<MavenBuild> { String buildMvnPath(Configuration config) throws IOException { Optional<String> binary = Optional.ofNullable(config.getStringByKeys("maven.binary", "MAVEN_BINARY")); File home = config.fileSystem().mavenHome(); if (home == null) { return binary.orElse(os.isWindows() ? "mvn.cmd" : "mvn"); } if (binary.isPresent()) { return new File(home, "bin/" + binary.get()).getCanonicalPath(); } if (os.isWindows()) { File bin = new File(home, "bin/mvn.bat"); if (bin.exists()) { return bin.getCanonicalPath(); } return new File(home, "bin/mvn.cmd").getCanonicalPath(); } return new File(home, "bin/mvn").getCanonicalPath(); } MavenBuildExecutor(Os os);  MavenBuildExecutor();  }
MavenBuildExecutor extends AbstractBuildExecutor<MavenBuild> { String buildMvnPath(Configuration config) throws IOException { Optional<String> binary = Optional.ofNullable(config.getStringByKeys("maven.binary", "MAVEN_BINARY")); File home = config.fileSystem().mavenHome(); if (home == null) { return binary.orElse(os.isWindows() ? "mvn.cmd" : "mvn"); } if (binary.isPresent()) { return new File(home, "bin/" + binary.get()).getCanonicalPath(); } if (os.isWindows()) { File bin = new File(home, "bin/mvn.bat"); if (bin.exists()) { return bin.getCanonicalPath(); } return new File(home, "bin/mvn.cmd").getCanonicalPath(); } return new File(home, "bin/mvn").getCanonicalPath(); } MavenBuildExecutor(Os os);  MavenBuildExecutor();   }