Skip to content

Commit 7a4ee8e

Browse files
committed
Choose right executable on Windows
1 parent 4ca5bfd commit 7a4ee8e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

platform-tooling-support-tests/platform-tooling-support-tests.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ dependencies {
5050
implementation(libs.groovy4) {
5151
because("it provides convenience methods to handle process output")
5252
}
53-
implementation(libs.opentest4j) {
54-
because("it throws TestAbortedException to abort tests")
53+
implementation(projects.junitJupiterApi) {
54+
because("it throws TestAbortedException to abort tests and uses the OS enum")
5555
}
5656

5757
testImplementation(libs.archunit) {

platform-tooling-support-tests/src/main/java/platform/tooling/support/process/ProcessStarters.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.nio.file.Path;
1414
import java.util.Optional;
1515

16+
import org.junit.jupiter.api.condition.OS;
1617
import org.opentest4j.TestAbortedException;
1718

1819
import platform.tooling.support.Helper;
@@ -45,17 +46,22 @@ public static ProcessStarter javaCommand(Path javaHome, String commandName) {
4546

4647
public static ProcessStarter gradlew() {
4748
var starter = new ProcessStarter() //
48-
.executable(Path.of("..").resolve("gradlew")) //
49+
.executable(Path.of("..").resolve(windowsOrOtherExecutable("gradlew.bat", "gradlew"))) //
4950
.putEnvironment("JAVA_HOME", getGradleJavaHome().orElseThrow(TestAbortedException::new));
5051
return withCommonEnvironmentVariables(starter);
5152
}
5253

5354
public static ProcessStarter maven() {
5455
var starter = new ProcessStarter() //
55-
.executable(Path.of(System.getProperty("mavenDistribution")).resolve("bin/mvn"));
56+
.executable(Path.of(System.getProperty("mavenDistribution")).resolve("bin").resolve(
57+
windowsOrOtherExecutable("mvn.cmd", "mvn")));
5658
return withCommonEnvironmentVariables(starter);
5759
}
5860

61+
private static String windowsOrOtherExecutable(String cmdOrExe, String other) {
62+
return OS.current() == OS.WINDOWS ? cmdOrExe : other;
63+
}
64+
5965
private static ProcessStarter withCommonEnvironmentVariables(ProcessStarter starter) {
6066
starter.putEnvironment("JUNIT_JUPITER_VERSION", Helper.version("junit-jupiter"));
6167
starter.putEnvironment("JUNIT_VINTAGE_VERSION", Helper.version("junit-vintage"));

0 commit comments

Comments
 (0)