Skip to content

Commit f13392e

Browse files
committed
fix: In CI for JDK 8, java.home may point to the JRE directory (/usr/lib/jvm/8/jre)
1 parent bea5f86 commit f13392e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

dd-java-agent/agent-ci-visibility/civisibility-test-fixtures/src/main/groovy/datadog/trace/civisibility/CiVisibilitySmokeTest.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,20 @@ abstract class CiVisibilitySmokeTest extends Specification {
2828
protected Path prefsDir
2929

3030
protected static String buildJavaHome() {
31-
return System.getProperty("java.home")
31+
def javaHome = System.getProperty("java.home")
32+
def javacPath = Paths.get(javaHome, "bin", "javac").toFile()
33+
if (javacPath.exists()) {
34+
return javaHome
35+
}
36+
// In CI for JDK 8, java.home may point to the JRE directory (e.g., /usr/lib/jvm/8/jre)
37+
// The JDK with javac is in the parent directory
38+
def parentDir = new File(javaHome).getParentFile()
39+
def parentJavacPath = new File(parentDir, Paths.get("bin", "javac").toString())
40+
if (parentJavacPath.exists()) {
41+
return parentDir.getAbsolutePath()
42+
}
43+
// Fallback to java.home and let callers handle the error if javac is not found
44+
return javaHome
3245
}
3346

3447
protected static String javaPath() {

0 commit comments

Comments
 (0)