How to set the main class in the assembly?

In sbt run , I have several options for the main class.

I would like to install the main class, so I wrote in build.sbt :

 mainClass := Some("aMainClass") 

But sbt does not work:

 build.sbt:1: error: not found: value aMainClass 

I also tried the project/Project.scala :

 import sbt._ class ExecutableProject(info: ProjectInfo) extends DefaultProject(info) { override def mainClass = Some("aMainClass") } 

mistake:

  project/Project.scala:3: not found: type aMainClass 

How to set the main class in the assembly?

+64
sbt
Jun 24 2018-11-11T00:
source share
2 answers

The main class must be fully equipped with the package:

 mainClass in Compile := Some("myPackage.aMainClass") 

This will work to run, and it will set the Main-Class in the manifest when using the package task. The main class for these tasks can be set separately, as in:

 mainClass in (Compile, run) := Some("myPackage.aMainClass") mainClass in (Compile, packageBin) := Some("myPackage.anotherMainClass") 

Note:

 mainClass := Some("myPackage.aMainClass") 

doing nothing. If you put this in your build file, you will not receive a warning that it is not doing anything.

+86
Aug 13 '13 at 0:19
source share

As far as I know, sbt expecting a fully qualified class / object name in your project here. For example, if your main class is as follows:

 package prog object Main extends App { // Hic sunt dracones } 

then you will need to specify your main class as follows:

 mainClass := Some("prog.Main") 

You get a type error because this type is not just found.

+22
Jun 24. '11 at 12:12
source share



All Articles