Skip to content

Commit

Permalink
Try to fix Maven and Gradle commands on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed Oct 1, 2024
1 parent 90b5a3e commit 57c34b2
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ void projectBuilds(Version bootVersion, Packaging packaging, Language language,
Path project = this.invoker.invokeProjectStructureGeneration(request).getRootDirectory();
Path home = acquireHome(buildSystem);
try {
ProcessBuilder processBuilder = createProcessBuilder(buildSystem, home);
processBuilder.directory(project.toFile());
ProcessBuilder processBuilder = createProcessBuilder(project, buildSystem, home);
Path output = TemporaryFiles.newTemporaryDirectory("ProjectGenerationIntegrationTests-projectBuilds")
.resolve("output.log");
processBuilder.redirectError(output.toFile());
Expand Down Expand Up @@ -162,17 +161,21 @@ private void releaseHome(BuildSystem buildSystem, Path home) {
}
}

private ProcessBuilder createProcessBuilder(BuildSystem buildSystem, Path home) {
private ProcessBuilder createProcessBuilder(Path directory, BuildSystem buildSystem, Path home) {
if (buildSystem.id().equals(MavenBuildSystem.ID)) {
ProcessBuilder processBuilder = new ProcessBuilder((isWindows()) ? "./mvnw.cmd" : "./mvnw",
"-Dmaven.repo.local=" + home.resolve("repository").toFile(), "package");
processBuilder.environment().put("MAVEN_USER_HOME", home.toFile().getAbsolutePath());
String command = (isWindows()) ? "mvnw.cmd" : "mvnw";
ProcessBuilder processBuilder = new ProcessBuilder(directory.resolve(command).toAbsolutePath().toString(),
"-Dmaven.repo.local=" + home.resolve("repository").toAbsolutePath(), "package");
processBuilder.environment().put("MAVEN_USER_HOME", home.toAbsolutePath().toString());
processBuilder.directory(directory.toFile());
return processBuilder;
}
if (buildSystem.id().equals(GradleBuildSystem.ID)) {
ProcessBuilder processBuilder = new ProcessBuilder((isWindows()) ? "./gradlew.bat" : "./gradlew",
String command = (isWindows()) ? "gradlew.bat" : "gradlew";
ProcessBuilder processBuilder = new ProcessBuilder(directory.resolve(command).toAbsolutePath().toString(),
"--no-daemon", "build");
processBuilder.environment().put("GRADLE_USER_HOME", home.toFile().getAbsolutePath());
processBuilder.environment().put("GRADLE_USER_HOME", home.toAbsolutePath().toString());
processBuilder.directory(directory.toFile());
return processBuilder;
}
throw new IllegalStateException("Unknown build system '%s'".formatted(buildSystem.id()));
Expand Down

0 comments on commit 57c34b2

Please sign in to comment.