Skip to content

Commit

Permalink
Use mvnw.cmd and gradlew.bat on Windows
Browse files Browse the repository at this point in the history
Also adds a Windows build.
  • Loading branch information
mhalbritter committed Oct 1, 2024
1 parent d1595ff commit 960a221
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-on-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build on Windows
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'liberica'
cache: 'maven'

- name: Build with Maven
run: ./mvnw --batch-mode --update-snapshots --no-transfer-progress verify
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import io.spring.initializr.web.project.WebProjectRequest;
import io.spring.start.testsupport.Homes;
import io.spring.start.testsupport.TemporaryFiles;
import org.apache.commons.lang3.SystemUtils;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.parallel.Execution;
Expand Down Expand Up @@ -163,17 +164,22 @@ private void releaseHome(BuildSystem buildSystem, Path home) {

private ProcessBuilder createProcessBuilder(BuildSystem buildSystem, Path home) {
if (buildSystem.id().equals(MavenBuildSystem.ID)) {
ProcessBuilder processBuilder = new ProcessBuilder("./mvnw",
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());
return processBuilder;
}
if (buildSystem.id().equals(GradleBuildSystem.ID)) {
ProcessBuilder processBuilder = new ProcessBuilder("./gradlew", "--no-daemon", "build");
ProcessBuilder processBuilder = new ProcessBuilder((isWindows()) ? "gradlew.bat" : "./gradlew",
"--no-daemon", "build");
processBuilder.environment().put("GRADLE_USER_HOME", home.toFile().getAbsolutePath());
return processBuilder;
}
throw new IllegalStateException("Unknown build system '%s'".formatted(buildSystem.id()));
}

private boolean isWindows() {
return SystemUtils.IS_OS_WINDOWS;
}

}

0 comments on commit 960a221

Please sign in to comment.