Skip to content

Commit a92494b

Browse files
author
Rafal Wojdyla
committed
Style + use split to support both scala 2.{10,11}
Compilation on Zeppelin travis fails on ClassPath missing method on scala 2.11. Use split and build URLs manually.
1 parent b884b72 commit a92494b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

scio/src/main/scala/org/apache/zeppelin/scio/ScioInterpreter.scala

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ package org.apache.zeppelin.scio
1919

2020
import java.beans.Introspector
2121
import java.io.PrintStream
22-
import java.util
22+
import java.net.URL
2323
import java.util.Properties
2424

2525
import com.google.cloud.dataflow.sdk.options.{PipelineOptions, PipelineOptionsFactory}
2626
import com.google.cloud.dataflow.sdk.runners.inprocess.InProcessPipelineRunner
2727
import com.spotify.scio.repl.{ScioILoop, ScioReplClassLoader}
2828
import org.apache.zeppelin.interpreter.Interpreter.FormType
29-
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion
3029
import org.apache.zeppelin.interpreter.util.InterpreterOutputStream
3130
import org.apache.zeppelin.interpreter.{Interpreter, InterpreterContext, InterpreterResult}
3231
import org.slf4j.LoggerFactory
@@ -70,11 +69,8 @@ class ScioInterpreter(property: Properties) extends Interpreter(property) {
7069

7170
val settings = new Settings()
7271

73-
// For scala 2.10 - usejavacp
74-
if (scala.util.Properties.versionString.contains("2.10.")) {
75-
settings.classpath.append(System.getProperty("java.class.path"))
76-
settings.usejavacp.value = true
77-
}
72+
settings.classpath.append(System.getProperty("java.class.path"))
73+
settings.usejavacp.value = true
7874

7975
def classLoaderURLs(cl: ClassLoader): Array[java.net.URL] = cl match {
8076
case null => Array()
@@ -90,22 +86,24 @@ class ScioInterpreter(property: Properties) extends Interpreter(property) {
9086
// itself to -Xplugin. If shell is started from sbt or classpath, paradise jar has to be in
9187
// classpath, we find it and add it to -Xplugin.
9288

93-
// Repl assembly includes paradise's scalac-plugin.xml - required for BigQuery macro
94-
// There should be no harm if we keep this for sbt launch.
9589
val thisJar = this.getClass.getProtectionDomain.getCodeSource.getLocation.getPath
9690
// In some cases this may be `target/classes`
9791
if(thisJar.endsWith(".jar")) settings.plugin.appendToValue(thisJar)
9892

99-
ClassPath.split(settings.classpath.value)
93+
ClassPath
94+
.split(settings.classpath.value)
10095
.find(File(_).name.startsWith("paradise_"))
10196
.foreach(settings.plugin.appendToValue)
10297

10398
// Force the repl to be synchronous, so all cmds are executed in the same thread
10499
settings.Yreplsync.value = true
105100

101+
val jars = ClassPath.split(settings.classpath.value)
102+
.flatMap(ClassPath.specToURL)
103+
.toArray
104+
106105
val scioClassLoader = new ScioReplClassLoader(
107-
ClassPath.toURLs(settings.classpath.value).toArray ++
108-
classLoaderURLs(Thread.currentThread().getContextClassLoader),
106+
jars ++ classLoaderURLs(Thread.currentThread().getContextClassLoader),
109107
null,
110108
Thread.currentThread.getContextClassLoader)
111109

0 commit comments

Comments
 (0)