Fix maven build on Windows

This commit is contained in:
Alex Boyko
2016-10-24 12:56:32 -04:00
parent 46e2334b0c
commit ea6079bea2
2 changed files with 156 additions and 150 deletions

View File

@@ -10,7 +10,7 @@ package org.springframework.ide.vscode.commons.maven;
* Contributors: * Contributors:
* Pivotal, Inc. - initial API and implementation * Pivotal, Inc. - initial API and implementation
*******************************************************************************/ *******************************************************************************/
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@@ -43,8 +43,11 @@ public class DependencyTreeTest {
*/ */
private static void buildProject(Path testProjectPath) throws Exception { private static void buildProject(Path testProjectPath) throws Exception {
if (!Files.exists(testProjectPath.resolve("classpath.txt"))) { if (!Files.exists(testProjectPath.resolve("classpath.txt"))) {
testProjectPath.resolve("mvnw").toFile().setExecutable(true); Path mvnwPath = System.getProperty("os.name").toLowerCase().startsWith("win")
ExternalProcess process = new ExternalProcess(testProjectPath.toFile(), new ExternalCommand("./mvnw", "clean", "package"), true); ? testProjectPath.resolve("mvnw.cmd") : testProjectPath.resolve("mvnw");
mvnwPath.toFile().setExecutable(true);
ExternalProcess process = new ExternalProcess(testProjectPath.toFile(),
new ExternalCommand(mvnwPath.toAbsolutePath().toString(), "clean", "package"), true);
if (process.getExitValue() != 0) { if (process.getExitValue() != 0) {
throw new RuntimeException("Failed to build test project"); throw new RuntimeException("Failed to build test project");
} }

View File

@@ -60,11 +60,14 @@ public class TestProjectHarness {
public Cache<String, IJavaProject> cache = CacheBuilder.newBuilder().build(); public Cache<String, IJavaProject> cache = CacheBuilder.newBuilder().build();
public IJavaProject mavenProject(String name) throws Exception { public IJavaProject mavenProject(String name) throws Exception {
Path testProjectPath = Paths.get(TestProjectHarness.class.getResource("/"+name).toURI()); Path testProjectPath = Paths.get(TestProjectHarness.class.getResource("/" + name).toURI());
assertTrue(Files.exists(testProjectPath)); assertTrue(Files.exists(testProjectPath));
if (!Files.exists(testProjectPath.resolve("classpath.txt"))) { if (!Files.exists(testProjectPath.resolve("classpath.txt"))) {
testProjectPath.resolve("mvnw").toFile().setExecutable(true); Path mvnwPath = System.getProperty("os.name").toLowerCase().startsWith("win")
ExternalProcess process = new ExternalProcess(testProjectPath.toFile(), new ExternalCommand("./mvnw", "clean", "package"), true); ? testProjectPath.resolve("mvnw.cmd") : testProjectPath.resolve("mvnw");
mvnwPath.toFile().setExecutable(true);
ExternalProcess process = new ExternalProcess(testProjectPath.toFile(),
new ExternalCommand(mvnwPath.toAbsolutePath().toString(), "clean", "package"), true);
if (process.getExitValue() != 0) { if (process.getExitValue() != 0) {
throw new RuntimeException("Failed to build test project"); throw new RuntimeException("Failed to build test project");
} }