aboutsummaryrefslogtreecommitdiff
path: root/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java')
-rw-r--r--launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java b/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java
index 39fdf300e2..91586aad7b 100644
--- a/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java
+++ b/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java
@@ -34,7 +34,7 @@ class CommandBuilderUtils {
/** The set of known JVM vendors. */
enum JavaVendor {
Oracle, IBM, OpenJDK, Unknown
- };
+ }
/** Returns whether the given string is null or empty. */
static boolean isEmpty(String s) {
@@ -349,4 +349,29 @@ class CommandBuilderUtils {
return Integer.parseInt(version[1]);
}
}
+
+ /**
+ * Find the location of the Spark jars dir, depending on whether we're looking at a build
+ * or a distribution directory.
+ */
+ static String findJarsDir(String sparkHome, String scalaVersion, boolean failIfNotFound) {
+ // TODO: change to the correct directory once the assembly build is changed.
+ File libdir;
+ if (new File(sparkHome, "RELEASE").isFile()) {
+ libdir = new File(sparkHome, "jars");
+ checkState(!failIfNotFound || libdir.isDirectory(),
+ "Library directory '%s' does not exist.",
+ libdir.getAbsolutePath());
+ } else {
+ libdir = new File(sparkHome, String.format("assembly/target/scala-%s/jars", scalaVersion));
+ if (!libdir.isDirectory()) {
+ checkState(!failIfNotFound,
+ "Library directory '%s' does not exist; make sure Spark is built.",
+ libdir.getAbsolutePath());
+ libdir = null;
+ }
+ }
+ return libdir != null ? libdir.getAbsolutePath() : null;
+ }
+
}