我有一个 Play 2.2 项目,我在工作中拆分了这就是我所做的:
文件夹结构:
项目:
project1
--project/Build.scala
project2
--project/Build.scala
project3
--project/Build.scala
project/Build.scala
下面是主要的 Build.scala 的样子:
import sbt._
import Keys._
object ApplicationBuild extends Build {
val appName = "test"
val appVersion = "test-0.1"
val ScalaVersion = "2.10.2"
val appDependencies = Seq(
)
lazy val project1 = RootProject(file("./project1/"))
lazy val project2 = RootProject(file("./project2/"))
lazy val project3 = RootProject(file("./project3/"))
lazy val mainProject = Project (
id = "test",
base = file("."),
settings = Project.defaultSettings).settings(
scalaVersion := ScalaVersion,
name := appName,
version := appVersion,
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/maven-releases/",
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
resolvers += "Typesafe snapshots" at "http://repo.typesafe.com/typesafe/snapshots/",
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
libraryDependencies ++= appDependencies
).aggregate(project1).aggregate(project2).aggregate(project3)
}
这将是构建所有子项目的平均 sbt 构建文件。
下面是 project2 的 Build.scala 文件的样子(在本例中是 Play 项目)
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "project2"
val appVersion = "1.0"
val appDependencies = Seq(
jdbc
)
lazy val project1 = RootProject(file("../project1"))
lazy val main = play.Project(appName, appVersion, appDependencies).settings(
scalaVersion := "2.10.2",
resolvers += Resolver.url("typesafe", url("http://repo.typesafe.com/typesafe/releases/")),
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
).dependsOn(project1)
}
基本上 project2 取决于 project1 的代码。
然后我将编辑主项目/plugins.sbt 文件并在此处添加 sbt 插件说明:https ://github.com/mpeltonen/sbt-idea (我使用快照版本)
然后使用 gen-idea 命令生成 intellij 项目。