The ways I know about so far are
-
Create an ant
build.xmlfile, make compile and run tasks, and include appropriate jars in aclasspath= -
Make at
sbtproject and include dependencies with version numbers inbuild.sbt -
Make a maven project and include dependencies in the xml file
-
Run from the command line setting
-classpathexplicitly
None of these are bad, but it feels like extra work after being babied with
import json
json.loads('[1, 2]')
and having that work right off the bat, provided I have json installed. In particular tracking down appropriate versions on Mavenhub gets a little tiresome.
Though maybe I’m just being too picky 😉
What you want is xsbtscript: https://github.com/paulp/xsbtscript
It allows you to create a single script file which includes both the sbt config your code requires along with the Scala code itself.