Skip to content

Commit 10d04b5

Browse files
committed
add if isJavaExecutableAvailable
1 parent 826ad69 commit 10d04b5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.nx/workflows/agents.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ launch-templates:
66
SERVICES_HOST: ""
77
LANG: C.UTF-8
88
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
9+
PATH: /usr/lib/jvm/java-17-openjdk-amd64/bin:/usr/local/bin:/usr/bin:/bin
910
resource-class: 'docker_linux_amd64/extra_large+'
1011
image: 'ubuntu22.04-node20.11-v10'
1112
init-steps:

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/src/test/java/smoketest/ant/SampleAntApplicationIT.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.TimeUnit;
2222

2323
import org.junit.jupiter.api.Test;
24+
import org.junit.jupiter.api.condition.EnabledIf;
2425

2526
import org.springframework.util.FileCopyUtils;
2627

@@ -35,6 +36,7 @@
3536
class SampleAntApplicationIT {
3637

3738
@Test
39+
@EnabledIf("isJavaExecutableAvailable")
3840
void runJar() throws Exception {
3941
File libs = new File("build/ant/libs");
4042
String javaExecutable = findJavaExecutable();
@@ -61,4 +63,19 @@ private String findJavaExecutable() {
6163
return "java";
6264
}
6365

66+
boolean isJavaExecutableAvailable() {
67+
try {
68+
String javaExecutable = findJavaExecutable();
69+
if (!javaExecutable.equals("java")) {
70+
return new File(javaExecutable).exists();
71+
}
72+
// Try to execute java to see if it's available in PATH
73+
ProcessBuilder pb = new ProcessBuilder("java", "-version");
74+
Process process = pb.start();
75+
return process.waitFor() == 0;
76+
} catch (Exception e) {
77+
return false;
78+
}
79+
}
80+
6481
}

0 commit comments

Comments
 (0)