I have a multi-project build configuration in SBT that consists of two distinct modules that do not depend on each other. They just (happen to) belong to the same product.
The project layout is as follows:
myLib
+ build.sbt
+ myProject_1
| + build.sbt
| + src
| + ...
+ myProject_2
| + build.sbt
| + src
| + ...
+ project
+ Build.scala
project/Build.scala contains common settings and looks like this:
import sbt._
import Keys._
object ApplicationBuild extends Build {
val appVersion = "1.0-SNAPSHOT"
val defaultScalacOptions = Seq(
"-unchecked", "-deprecation", "-feature", "-language:reflectiveCalls",
"-language:implicitConversions", "-language:postfixOps",
"-language:dynamics", "-language:higherKinds", "-language:existentials",
"-language:experimental.macros", "-Xmax-classfile-name", "140")
val defaultResolvers = Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
)
val defaultLibraryDependencies = Seq(
"org.specs2" %% "specs2" % "1.14" % "test",
"org.slf4j" % "slf4j-nop" % "1.7.5" % "test"
)
val defaultSettings = Defaults.defaultSettings ++ Seq(
scalacOptions ++= defaultScalacOptions,
resolvers ++= defaultResolvers,
libraryDependencies ++= defaultLibraryDependencies
)
}
The root build file build.sbt is just needed to put all together [I also tried to remove it.. but then the sub-projects don't get compiled anymore]:
lazy val myProject_1 = project.in(file("myProject_1"))
lazy val myProject_2 = project.in(file("myProject_2"))
And finally here is myProject_1/build.sbt [I have just omitted myProject_2/build.sbt because it is very similar and does not provide any added value for the topic]:
name := "myProject_1"
version := ApplicationBuild.appVersion
ApplicationBuild.defaultSettings
libraryDependencies ++= Seq(
"commons-codec" % "commons-codec" % "1.8"
)
The project compiles successfully... but when I issue the command sbt package
, then an empty jar is generated in the root target directory:
j3d@gonzo:~/myLib/$ ll target/scala-2.10
drwxrwxr-x 2 j3d j3d 4096 Dez 23 17:13 ./
drwxrwxr-x 5 j3d j3d 4096 Dez 23 17:13 ../
-rw-rw-r-- 1 j3d j3d 273 Dez 23 17:13 brix_2.10-0.1-SNAPSHOT.jar
Am I missing something? How can I prevent SBT from generating this empty and useless jar?