1

I'm sure I've seen a page that shows how to put SBT instructions inside a scala file, instead of build.sbt. The advantage is that everything then lives in a single file, which makes it easier to use Scala as a scripting language.

But I can't now find the example... can anyone help?

BTW, I know about ammonite, but it has limitations compared to SBT.

Mohan
  • 4,674
  • 5
  • 26
  • 45

2 Answers2

1

I think you're looking for this page of the sbt docs: Scripts, REPL, and Dependencies. There are also some other resources on the topic:

  • an example project by Eric Richardson with detailed instructions: ekrich/sbt-scripting
  • a post by Eugene Yokota (maintainer of sbt): scripting with Scala (it's from 2014, so I'm not sure if it's still relevant)
  • an example script gist by Seth Tisue
laughedelic
  • 5,499
  • 1
  • 24
  • 34
0

You can create your customize scala file under project/ directory and import it in build.sbt, like:

├── build.sbt
└── project
    └── Settings.scala

so you can import it in build.sbt:

import Settings._
chengpohi
  • 13,467
  • 1
  • 21
  • 40
  • Errr... I'm trying to get everything in a single file! I know it's possible; I've seen an example somewhere on the internet... – Mohan Sep 03 '18 at 13:19
  • @Mohan, so you mean [Build.scala](https://stackoverflow.com/questions/18000103/what-is-the-difference-between-build-sbt-and-build-scala) but it is deprecated. – chengpohi Sep 03 '18 at 13:33