Skip to content

Commit 3eeec30

Browse files
author
Marcelo Vanzin
committed
Use JAVA_HOME when available, java.home otherwise.
1 parent d71f1bb commit 3eeec30

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

pom.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@
159159
<snappy.version>1.1.1.6</snappy.version>
160160
<netlib.java.version>1.1.2</netlib.java.version>
161161

162+
<test.java.home>${java.home}</test.java.home>
163+
162164
<!--
163165
Dependency scopes that can be overridden by enabling certain profiles. These profiles are
164166
declared in the projects that build assemblies.
@@ -1194,7 +1196,7 @@
11941196
launched by the tests have access to the correct test-time classpath.
11951197
-->
11961198
<SPARK_DIST_CLASSPATH>${test_classpath}</SPARK_DIST_CLASSPATH>
1197-
<JAVA_HOME>${java.home}</JAVA_HOME>
1199+
<JAVA_HOME>${test.java.home}</JAVA_HOME>
11981200
</environmentVariables>
11991201
<systemProperties>
12001202
<java.awt.headless>true</java.awt.headless>
@@ -1225,7 +1227,7 @@
12251227
launched by the tests have access to the correct test-time classpath.
12261228
-->
12271229
<SPARK_DIST_CLASSPATH>${test_classpath}</SPARK_DIST_CLASSPATH>
1228-
<JAVA_HOME>${java.home}</JAVA_HOME>
1230+
<JAVA_HOME>${test.java.home}</JAVA_HOME>
12291231
</environmentVariables>
12301232
<systemProperties>
12311233
<java.awt.headless>true</java.awt.headless>
@@ -1718,6 +1720,16 @@
17181720
</modules>
17191721
</profile>
17201722

1723+
<profile>
1724+
<id>test-java-home</id>
1725+
<activation>
1726+
<property><name>env.JAVA_HOME</name></property>
1727+
</activation>
1728+
<properties>
1729+
<test.java.home>${env.JAVA_HOME}</test.java.home>
1730+
</properties>
1731+
</profile>
1732+
17211733
<profile>
17221734
<id>scala-2.11</id>
17231735
<activation>

project/SparkBuild.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ object SparkBuild extends PomBuild {
119119
lazy val publishLocalBoth = TaskKey[Unit]("publish-local", "publish local for m2 and ivy")
120120

121121
lazy val sharedSettings = graphSettings ++ genjavadocSettings ++ Seq (
122-
javaHome := sys.props.get("java.home").map(file),
122+
javaHome := sys.env.get("JAVA_HOME")
123+
.orElse(sys.props.get("java.home").map { p => new File(p).getParentFile().getAbsolutePath() })
124+
.map(file),
123125
incOptions := incOptions.value.withNameHashing(true),
124126
retrieveManaged := true,
125127
retrievePattern := "[type]s/[artifact](-[revision])(-[classifier]).[ext]",
@@ -429,7 +431,7 @@ object TestSettings {
429431
envVars in Test ++= Map(
430432
"SPARK_DIST_CLASSPATH" ->
431433
(fullClasspath in Test).value.files.map(_.getAbsolutePath).mkString(":").stripSuffix(":"),
432-
"JAVA_HOME" -> sys.props("java.home")),
434+
"JAVA_HOME" -> sys.env.get("JAVA_HOME").getOrElse(sys.props("java.home"))),
433435
javaOptions in Test += "-Dspark.test.home=" + sparkHome,
434436
javaOptions in Test += "-Dspark.testing=1",
435437
javaOptions in Test += "-Dspark.port.maxRetries=100",

0 commit comments

Comments
 (0)