Skip to main content

In case your project outgrows the cabapilities of Scala CLI (e.g support for modules) it may be beneficial to switch to a build tool such as SBT or Mill. The export sub-command allows to do that by converting a Scala CLI project into an SBT or Mill configuration. Additionally the sub-command supports the JSON format for custom analysis of projects.

Results of running the with --mill or --sbt sub-command are, by default, put in ./dest/, that behaviour can be modified by specifying a path with the --output option.

The default behaviour of exporting with the --json option is printing to standard output.


The export sub-command is restricted and requires setting the --power option to be used. You can pass it explicitly or set it globally by running:

scala-cli config power true


The export sub-command is an experimental feature.

Please bear in mind that non-ideal user experience should be expected. If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team on GitHub.

The project configuration is read both from information specified in source files as well as options passed to the export sub-command.

Let's take a simple one-file project as an example:

//> using scala 3.1.3
//> using option -Xasync
//> using dep com.lihaoyi::os-lib:0.9.0

object Hello {
def main(args: Array[String]): Unit =

Exporting to SBT:

scala-cli --power export Hello.scala --sbt

Note that --sbt is not required here since it's the default.

The result is an sbt-compliant project created in the dest/ directory:

├── project
│ └──
├── src
│ └── main
│ └── scala
│ └── Hello.scala
└── build.sbt

All the project's configuration resides now in dest/build.sbt:

scalaVersion := "3.1.3"

scalacOptions ++= Seq("-Xasync")

libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.9.0"

libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.9.0" % Test

To configure the version of SBT used in the new project provide the --sbtVersion option to the export sub-command.

Exporting to Mill:

scala-cli --power export Hello.scala --mill --output=dest_mill

Mill is not the default export format, so passing the --mill option is required.

By specifying the path with --output option the results are now created in dest_mill/ directory:

├── project
│ └── src
│ └── Hello.scala
├── .mill-version
├── mill
└── mill.bat

And all the project's configuration resides now in dest_mill/

import mill._
import mill.scalalib._
object project extends ScalaModule {
def scalaVersion = "3.1.3"
def scalacOptions = super.scalacOptions() ++ Seq("-Xasync")
def ivyDeps = super.ivyDeps() ++ Seq(

object test extends Tests {
def ivyDeps = super.ivyDeps() ++ Seq(

The script files mill and mill.bat are mill wrappers fetched from lefou/millw repository. To change the build tool version used override the contents of dest_mill/.mill-version.

Exporting to JSON:

To export project information in a human-comprehensible format, use the --json flag. By default, exporting with the --json option prints to standard output, this can be changed with --output parameter by specifying a directory where to create the export.json file.

scala-cli --power export Hello.scala --json --output=dest_json

The result is the dest_json/export.json file:

"scalaVersion": "3.1.3",
"platform": "JVM",
"scopes": {
"main": {
"sources": [
"scalacOptions": [
"dependencies": [
"groupId": "com.lihaoyi",
"artifactId": {
"name": "os-lib",
"fullName": "os-lib_3"
"version": "0.9.0"
"resolvers": [