1.定义项目
lazy val util = project
lazy val core = project
2.修改项目根目录
lazy val util = (project in file("util"))
lazy val core = (project in file("core"))
3.设置公共配置
lazy val commonSettings = Seq(
organization := "com.example",
version := "0.1.0",
scalaVersion := "2.12.2"
)
lazy val core = (project in file("core"))
.settings(
commonSettings,
// other settings
)
lazy val util = (project in file("util"))
.settings(
commonSettings,
// other settings
)
4.设置依赖
第一种,依赖包管理
lazy val commonDeps = common
val common = Seq(
"com.typesafe" % "config" % "1.3.0",
"junit" % "junit" % "4.12",
"org.specs2" % "specs2_2.10" % "2.5" % "test",
"com.typesafe.play" %% "play-json" % "2.3.8"
)
lazy val util = (project in file("util"))
.settings(
libraryDependencies ++= Dependencies.commonDeps,
)
第二种,依赖另一个项目的依赖
lazy val core = project in file("core")
lazy val util = (project in file("util"))
.settings(
libraryDependencies ++= Dependencies.commonDeps
//key libraryDependencies 包含两个方面的复杂性:+= 方法而不是 :=,第二个就是 % 方法。
//+=方法是将新的值追加该 key 的旧值后面而不是替换它
).dependsOn(core)
//这种