Using ijar poses a challenge in Scala because Scala macros are resolved during compilation. If a Scala macro references methods stripped away by ijar, things break.
However, forgoing ijar
use altogether is sub-optimal---using ijar
dramatically decreases unnecessary recompilation between builds.
higherkindness/rules_scala
strives to optimally integrate ijar
and Scala macros as follows:
scala_library
,scala_binary
, andscala_test
have a Booleanmacro
attribute which must be set to true if the rule contains any Scala macros- During the classpath resolution phase, we set
macro_classpath
to contain the transitive runtime classpaths of alldeps
for whichmacro = true
- We let
JavaInfo
always useijar
- If
macro
was false, we get useful ijars - If
macro
was true, we get problematic ijars; however, this won't be an issue:
- If
- During compilation, we have
macro_classpath
precede the compile classpath of the mergedJavaInfo
, forcing the compiler to use the full classes
This lets us make use of ijars as much as possible, without breaking things due to Scala macro usage.