alexarchambault on 1.6.3
alexarchambault on master
1.6.3 (compare)
lihaoyi on gh-pages
5ad9ae5538f23cab92ccd8c6b1617d8… (compare)
alexarchambault on master
Partly revert 84d48542 (#923) … (compare)
Hi all, I'm working to embed Ammonite in my application, and I'd like to be able to pass an object from the application to the Ammonite environment, e.g.
def my_entrypoint(foo: Foo) = {
// Make `foo` accessible from the script.
ammonite.Main(...).runScript(...)
}
I see the run
method on Main
would allow me to do this, but I want to be able to do this when running a script non-interactively - are there any methods that would allow me to achieve this?
I managed to get it working without a threadlocal with this:
ammoniteMain
.instantiateRepl(IndexedSeq("foo" -> foo)).map { repl =>
repl.interp.initializePredef()
ammonite.main.Scripts.runScript(...)
}
The only issue is that it doesn't seem to pick up the @main
annotations.
@ import scala.collection.JavaConverters.asScalaBufferConverter
import scala.collection.JavaConverters.asScalaBufferConverter
@ val tmp: Buffer[String] = flavors.getNativesForFlavor(DataFlavor.imageFlavor)
cmd44.sc:1: type mismatch;
found : java.util.List[String]
required: scala.collection.mutable.Buffer[String]
val tmp: Buffer[String] = flavors.getNativesForFlavor(DataFlavor.imageFlavor)
^
Compilation Failed
@
os.proc().spawn
. You cannot fork JVMs https://jukkaz.wordpress.com/2010/05/27/forking-a-jvm/
I’m trying to follow the steps to add Ammonite to an SBT project. Now when I run Test / compile
it fails with:
[error] error while loading Object, Missing dependency 'object scala.native in compiler mirror', required by /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/rt.jar(java/lang/Object.class)
[error] ## Exception when compiling 1 sources to /Users/jason/source/console-api/target/scala-2.13/test-classes
[error] scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
…
This is with sbt 1.3.5 and Scala 2.13.1