我已按照构建代码进行多项目设置:
import sbt._
import Keys._
import com.typesafe.sbt.SbtScalariform._
import scalariform.formatter.preferences._
import sbtunidoc.Plugin._
object DirectorynameBuild extends Build {
addCommandAlias("rebuild", ";clean; compile; package")
lazy val BoundedContext = Project(id = "BoundedContext",
base = file("."),
settings = commonSettings).aggregate(
persistence,
core,
biz,
protocol,
transport)
lazy val persistence = Project(id = "BoundedContext-persistence",
settings = commonSettings,
base = file("persistence")) dependsOn (protocol)
lazy val core = Project(id = "BoundedContext-core",
settings = commonSettings,
base = file("core")) dependsOn (
persistence,
biz,
protocol)
lazy val biz = Project(id = "BoundedContext-biz",
settings = commonSettings,
base = file("biz")) dependsOn (protocol)
lazy val protocol = Project(id = "BoundedContext-protocol",
settings = commonSettings,
base = file("protocol"))
lazy val transport = Project(id = "BoundedContext-transport",
settings = commonSettings,
base = file("transport")) dependsOn(protocol)
val ORGANIZATION = "my.first.ddd.app"
val PROJECT_NAME = "directoryname"
val PROJECT_VERSION = "0.1-SNAPSHOT"
val SCALA_VERSION = "2.11.4"
val TYPESAFE_CONFIG_VERSION = "1.2.1"
val SCALATEST_VERSION = "2.2.2"
val SLF4J_VERSION = "1.7.9"
val LOGBACK_VERSION = "1.1.2"
lazy val commonSettings = Project.defaultSettings ++
basicSettings ++
formatSettings ++
net.virtualvoid.sbt.graph.Plugin.graphSettings
lazy val basicSettings = Seq(
version := PROJECT_VERSION,
organization := ORGANIZATION,
scalaVersion := SCALA_VERSION,
libraryDependencies ++= Seq(
"com.typesafe" % "config" % TYPESAFE_CONFIG_VERSION,
"org.slf4j" % "slf4j-api" % SLF4J_VERSION,
"ch.qos.logback" % "logback-classic" % LOGBACK_VERSION % "runtime",
"org.scalatest" %% "scalatest" % SCALATEST_VERSION % "test"
),
scalacOptions in Compile ++= Seq(
"-unchecked",
"-deprecation",
"-feature"
),
/*javaOptions += "-Djava.library.path=%s:%s".format(
sys.props("java.library.path")
),*/
fork in run := true,
fork in Test := true,
parallelExecution in Test := false
)
lazy val formatSettings = scalariformSettings ++ Seq(
ScalariformKeys.preferences := FormattingPreferences()
.setPreference(IndentWithTabs, false)
.setPreference(IndentSpaces, 2)
.setPreference(AlignParameters, false)
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(MultilineScaladocCommentsStartOnFirstLine, false)
.setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
.setPreference(PreserveDanglingCloseParenthesis, true)
.setPreference(CompactControlReadability, true)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(PreserveSpaceBeforeArguments, true)
.setPreference(SpaceBeforeColon, false)
.setPreference(SpaceInsideBrackets, false)
.setPreference(SpaceInsideParentheses, false)
.setPreference(SpacesWithinPatternBinders, true)
.setPreference(FormatXml, true)
)
//credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
}
我没有在根文件夹中定义src/main/scala
。
我可以使用sbt "project ****" run
运行单个项目
如果我按照命令sbt run
,那么我就会检测到#34;没有检测到主要类别"
我可以看到lagom框架很容易实现我想要的过程。但我无法弄清楚这个过程。
如何在不使用src/main/scala/***App.scala
的情况下运行主项目?