Set mainClass for sbt native packager Universal

73 views Asked by At

I have a project that has the following build.sbt:

addCommandAlias("package", "dist")

lazy val actual = (project in file("."))
  .enablePlugins(UniversalPlugin, JavaServerAppPackaging)
  .settings(
    name := "DeployerPod",
    mainClass := Some("com.myself.executable.Runner"),
    Compile / mainClass := Some("com.myself.executable.Runner"),
    Compile / run / mainClass := Some("com.myself.utils.Pipeline"),
    Universal / mainClass := Some("com.myself.executable.Runner"),
    Universal / compile / mainClass := Some("com.myself.executable.Runner"),
  )

We have a CICD which runs a Dockerfile. There I have sbt run as one of the steps, which will execute com.myself.utils.Pipeline class to run a Scala class and do the pre requisites for the pipeline.

As one of the last sbt based steps, I'm also running sbt package, which eventually runs an sbt dist command. At this point, inside the extracted ZIP's bin folder, I see two BAT files corresponding to the two main classes. Unfortunately I only want the Runner class BAT instead of Pipeline BAT.

For this I tried running sbt package -main com.myself.executable.Runner but that failed saying Not a valid command: -

Is there a way I can specify the mainClass only for this Universal plugin somehow? Because the way I've tried in my build.sbt doesn't seem to work.

0

There are 0 answers