opened
sdtwigg
username_0
In _compile, compiler_classpath is the union of all jars in scalareflect, scalalib, scalacompiler and 'jars' (which is the compile time jars of deps and exports of deps).

However, when constructing the runtime classpath for both scala_library and scala_binary, only scalalib and scalareflect are added.

The scala compiler is added as a compiletime dependency to the invocation of scalac by being added to the compiler_classpath. However, the rjars list for scala_library (used to setup runfiles and transitive_runtime_deps) and scala_binary (used to setup the classpath for executing the binary) does NOT include scalacompiler. Amusingly, scala_repl does (because scalacompiler includes the main for the repl and that binary would not execute otherwise).

Everything seems to work if you just drop scalacompiler from the compiler_classpath.

PS: This was discovered as part of my push to avoid the use file or files for referencing jars (instead preferring that _collect_jars be used). Thus, as a side question, in _compile, the "Classpath: {cp}" (built up as compiler_classpath above that) argument to scalac worker is specifically the classpath for compiling the current set of incoming sources, NOT the classpath for running scalac. Right?

I am fairly certain the scalac classpath is independently handled by the java_library/java_binary chain and thus isolated from the classpath used to 'understand' the files-to-be-compiled. Thus, when scalac is 'booting itself' it is drawing from THAT classpath and then later. This interpretation would all be consistent with everything still working when scalacompiler is dropped from compiler_classpath.

PPS: I think compilation_classpath would be more accurate than compiler_classpath. compilation_classpath better implies it is the classpath for understanding the artifacts to compile whereas compiler_classpath implies this is the classpath for running the compiler....

Also, I think it might be clearer if _compile did not add any extra jars to the classpath but instead _lib, _scala_binary_impl, etc. appended those jars before passing into _compile. The ultimate goal is to make it 'more clear and consistent' how all these lists of jars are being setup.
scalacompiler on compile classpath but not runtime classpath for scala_library|binary
issue
created
johnynek
username_1
I don't think you need the compiler on the runtime classpath in general. If your target needs it,I think you should add the declaration. 

I think it should only be on the compile classpath for macro targets. I don't think it should generally be needed otherwise, and users should be explicit if they do need it.

I totally agree we should do anything we can to make things more clear. Welcome any PR in that direction.
comment
created
sdtwigg
username_0
Yep, am working on a PR for this. It had started as part of the JavaProvider work but I'm going to cleave this cleanup off as its own thing.
comment
closed
sdtwigg
username_0
issue