scala - How to set default dependencies for all subprojects in SBT? -
trying understand how set sbt subprojects. correct way set default dependencies sub projects?
i tried this, sub projects weren't picking of dependencies (they downloaded fine).
import sbt._ class myprojects(info: projectinfo) extends defaultproject(info) { val proja = project("proja", "projecta") val projb = project("projb", "projectb") val akkarepo = "akka maven2 repo" @ "http://www.scalablesolutions.se/akka/repository/" val multiverserepo = "multiverse maven2 repo" @ "http://multiverse.googlecode.com/svn/maven-repository/releases/" val guiceyfruitrepo = "guiceyfruit maven2 repo" @ "http://guiceyfruit.googlecode.com/svn/repo/releases/" val jbossrepo = "jboss maven2 repo" @ "https://repository.jboss.org/nexus/content/groups/public/" val junit = "junit" % "junit" % "4.5" % "test" val scalatest = "org.scalatest" % "scalatest" % "1.2" % "test" val akka = "se.scalablesolutions.akka" % "akka-core_2.8.0" % "0.10" }
then, based on this tried following. worked, it's not expecting have do. isn't there simpler set default dependencies subprojects?
import sbt._ class myprojects(info: projectinfo) extends defaultproject(info) { val proja = project("proja", "projecta", new proj(_)) val projb = project("projb", "projectb", new proj(_)) val akkarepo = "akka maven2 repo" @ "http://www.scalablesolutions.se/akka/repository/" val multiversrepo = "multiverse maven2 repo" @ "http://multiverse.googlecode.com/svn/maven-repository/releases/" val guiceyfruitrepo = "guiceyfruit maven2 repo" @ "http://guiceyfruit.googlecode.com/svn/repo/releases/" val jbossrepo = "jboss maven2 repo" @ "https://repository.jboss.org/nexus/content/groups/public/" class proj(info:projectinfo) extends defaultproject(info){ val junit = "junit" % "junit" % "4.5" % "test" val scalatest = "org.scalatest" % "scalatest" % "1.2" % "test" val akka = "se.scalablesolutions.akka" % "akka-core_2.8.0" % "0.10" } }
edit: should point out there better way use akka, illustrating point.
use inheritance , mixins:
import sbt._ class modularproject(info: projectinfo) extends defaultproject(info){ lazy val childproject = project("proja", "projecta", new defaultproject(_) repositories globaldependencies akkadependencies) trait repositories{ lazy val akkarepo = "akka maven2 repo" @ "http://www.scalablesolutions.se/akka/repository/" lazy val multiversrepo = "multiverse maven2 repo" @ "http://multiverse.googlecode.com/svn/maven-repository/releases/" lazy val guiceyfruitrepo = "guiceyfruit maven2 repo" @ "http://guiceyfruit.googlecode.com/svn/repo/releases/" lazy val jbossrepo = "jboss maven2 repo" @ "https://repository.jboss.org/nexus/content/groups/public/" } trait globaldependencies{ lazy val junit = "junit" % "junit" % "4.5" % "test" lazy val scalatest = "org.scalatest" % "scalatest" % "1.2" % "test" } trait akkadependencies{ lazy val akka = "se.scalablesolutions.akka" % "akka-core_2.8.0" % "0.10" } }
Comments
Post a Comment