title: Suppress main class in sbt-assembly
body: <p>In a multi-project SBT build, how should one explicitly suppress the mainClass attribute in SBT-assembly?</p>
  
  <p>I've searched extensively but cannot seem to find out how to prevent a main class from being set in the jar built by sbt-assembly in a multi-project build.</p>
  
  <p>In a single-project build, this seems to work as long as there are at least two classes that might potentially be invoked by command line:</p>
  
  <pre><code>import sbt._
  import Keys._
  
  import sbtassembly.Plugin._
  import sbtassembly.AssemblyUtils._
  import AssemblyKeys._
  
  object TestBuild extends Build {
    lazy val buildSettings = Defaults.defaultSettings ++ assemblySettings ++ Seq(
      version := "0.1-SNAPSHOT",
      organization := "com.organization",
      scalaVersion := "2.10.2",
      mergeStrategy in assembly := mergeFirst
    )
  
    lazy val root = Project(id = "test-assembly",
      base = file("."),
      settings = buildSettings) settings(
      mainClass in assembly := None
    )
    lazy val mergeFirst: String =&gt; MergeStrategy = { 
      case "reference.conf" | "rootdoc.txt" =&gt; MergeStrategy.concat
      case PathList("META-INF", xs @ _*) =&gt;
      (xs map {_.toLowerCase}) match {
        case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =&gt;
        MergeStrategy.discard
        case ps @ (x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") =&gt;
        MergeStrategy.discard
        case "plexus" :: xs =&gt;
        MergeStrategy.discard
        case "services" :: xs =&gt;
        MergeStrategy.filterDistinctLines
        case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) =&gt;
        MergeStrategy.filterDistinctLines
        case _ =&gt; MergeStrategy.first
      }
      case _ =&gt; MergeStrategy.first
    }
  }
  </code></pre>
  
  <p>However, it appears that the <code>mainClass := None</code> isn't even necessary. In fact, even if it is left there, a main class will still be set in the manifest if there is only one candidate class.</p>
  
  <p>Unforunately, in a multi-project build, I could not prevent a main class from being set even by including an additional class as a dummy entry-point.</p>
  
  <p>After a lot of fiddling around, I found that I could prevent a main class from being set by setting <code>mainClass</code> to <code>None</code> in several scopes independently. In particular, this does the trick:</p>
  
  <pre><code>mainClass in assembly := None
  mainClass in packageBin := None
  nainClass in Compile := None
  mainClass in run := None
  </code></pre>
  
  <p>I could not find this requirement stated in the documentation and cannot figure out why this is necessary. Setting <code>mainClass in (Compile, run) := None</code> does not work. They really need to be scoped separately.</p>
  
  <p>Is this the proper way to manually suppress a main class or am I missing something? If not a bug, I think this should be documented somewhere, especially given that the behavior is not consistent between single- and multi-project builds.</p>