mattpap / IScala

Scala backend for IPython
MIT License
322 stars 49 forks source link

Add classpath #2

Closed markusgumbel closed 10 years ago

markusgumbel commented 10 years ago

IScala is already a very interesting tool! Thanks!

Is it possible to add a classpath to include any jars or class files? Perhaps this is possible via sbt but I do not know sbt very well. The idea is to be able to use the notebook for Scala classes which are under development.

mattpap commented 10 years ago

IScala is already a very interesting tool! Thanks!

Thanks.

Is it possible to add a classpath to include any jars or class files?

Yes. Suppose class files are located in my_project/target/scala-2.10/classes. Then issue:

$ java -jar target/lib/IScala.jar -- -classpath my_project/target/scala-2.10/classes

and connect IPython client to this kernel. You can pass any command line argument after -- that scalac supports. Note that if you recompile your project, then you need to reset the kernel (with %reset from a client) to make changes to classpath visible in the kernel. If you want to add library dependencies then you may want to use built-in support for sbt (see README for details).

Unfortunately, scripts in bin/ (target/bin/ after ./sbt release if you are using source repository) don't allow --, failing with joptsimple.UnrecognizedOptionException. This needs to be fixed.

mattpap commented 10 years ago

Now IScala.jar and bin/* scripts support classpath directly and can resolve dependencies through sbt-ivy, e.g.:

$ bin/2.11/console -m org.parboiled::parboiled:2.0.1 -c ~/repo/bokeh-scala/bokeh/target/scala-2.11/classes
Listening for transport dt_socket at address: 5005
[info] Resolving org.parboiled#parboiled_2.11;2.0.1 ...
[info] Resolving org.scala-lang#scala-library;2.11.2 ...
[info] Resolving com.chuusai#shapeless_2.11;2.0.0 ...
Welcome to Scala 2.11.2 (OpenJDK 64-Bit Server VM, Java 1.6.0_31)

In [1]: import org.parboiled2._

In [2]: import io.continuum.bokeh._

In [3]: