By Alvin Alexander. Last updated: October 14, 2021
As a quick note to self, I just used these contents in a Scala/sbt build.sbt file when working with the GraalVM native-image command (and sbt plugin). I share these here so I can remember how to specify command-line options for the native-image plugin in the build.sbt file:
lazy val sbtmkdirs = (project in file(".")) .enablePlugins(NativeImagePlugin) .settings( name := "http_client", version := "0.1", scalaVersion := "3.0.1", Compile / mainClass := Some("foo.HttpClient"), // these are the native-image options i used // to work with HTTP and HTTPS (though I don’t know // if they are all needed) nativeImageOptions ++= Seq( "-H:EnableURLProtocols=http", "-H:EnableURLProtocols=https", "--enable-url-protocols=http,https", "--enable-https", "--enable-http" ) ) scalacOptions ++= Seq( "-deprecation", "-explain", "-explain-types", "-new-syntax", "-unchecked", "-Xfatal-warnings", "-Xmigration" )
It’s also helpful to see that sbt/build.sbt Compile / mainClass
syntax, because that’s currently hard to find on the internet