[SI-6660] REPL: load transitive dependencies of JARs on classpath Created: 13/Nov/12  Updated: 19/Apr/15  Due: 01/Feb/13

Status: Open
Project: Scala Programming Language
Component/s: Repl / Interpreter
Affects Version/s: Scala 2.10.0
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Stefan Zeiger Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None


The Scala REPL should load dependencies referenced in MANIFEST.MF files of other JARs on the classpath.

As described in https://support.typesafe.com/tickets/1585:

We have JAR files that contain standard META-INF/MANIFEST.MF files with the Class-Path: entry. This entry points to a number of other JARs that should be loaded transitively by the ClassLoader. Unfortunately the REPL does not load these transitive dependencies, instead dependency JARs need to be placed on the classpath explicitly one by one.

As an example let's say I have A.jar and B.jar. I also have a C.jar that has nothing else in it than a MANIFEST.MF with 'Class-Path: A.jar B.jar'. If I use

> scala -classpath A.jar;B.jar

everything is ok. I can e.g import A and import B. However, if I use

> scala -classpath C.jar

I couldn't import or use any classes from A.jar or B.jar.

Comment by Li Haoyi [ 19/Apr/15 ]

This works in the Ammonite REPL, not with raw jar files, but you can specify any coordinate on maven central and the REPL will pull down any transitive dependencies necessary. e.g. here I am asking for `upickle` and getting `jawn-parser` for free:

@ load.ivy("com.lihaoyi" %% "upickle" % "0.2.6")
:: resolving dependencies :: com.lihaoyi#upickle_2.11-caller;working
	confs: [default]
	found com.lihaoyi#upickle_2.11;0.2.6 in central
	found org.scala-lang#scala-library;2.11.4 in central
	[2.11.4] org.scala-lang#scala-library;2.11.4
	found org.spire-math#jawn-parser_2.11;0.7.0 in central
	found com.lihaoyi#acyclic_2.11;0.1.2 in central
	found org.scala-lang#scala-compiler;2.11.0 in central
	found org.scala-lang.modules#scala-xml_2.11;1.0.1 in central
	found org.scala-lang.modules#scala-parser-combinators_2.11;1.0.1 in central
	found org.scala-lang#scala-reflect;2.11.4 in central
	[2.11.4] org.scala-lang#scala-reflect;2.11.4
res17: Unit = ()
@ import upickle._
import upickle._
@ upickle.write(Seq(1, 2, 3))
res19: String = "[1,2,3]"

Generated at Tue Dec 18 14:21:52 CET 2018 using JIRA 7.9.1#79001-sha1:60970b42586a2ec2760ed6cfe825b26961e62b9e.