Play Framework:多模块项目

时间:2016-05-12 00:48:55

标签: scala intellij-idea playframework sbt typesafe-activator

我创建了一个具有以下结构的多模块项目:

my_app  
|__app  
|__conf  
|__public  
|__project  
|  |__CommonBuild.scala  
|__core  
|  |__src/main/scala  
|  |__src/test/scala      
|  |__build.sbt  
|__build.sbt  

我注意到2个问题:

  1. 在开发模式下,当我执行activator run并对core模块进行更改时,我发现它重新编译但在运行时它会在本地获取已发布的core-[ver].jar依赖项而不是模块
  2. 在IntelliJ IDEA中,我看到了同样的问题。在my_app的项目结构下,我确实将核心添加为模块和jar。
  3. CommonBuild.scala

    object CommonBuild {
      val settings: Seq[Setting[_]] = Seq(
         organization = "com.myorg",
         scalaVersion = "2.11.8",
         transitiveClassifiers in Global := Seq(Artifact.SourceClassifier),
         resolvers ++= Seq(
             "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
         ),
         aggregate in update := false,
         parallelExecution in Test := false,
         Keys.fork in Test := false,
         libraryDependencies ++= Seq(/*all dependencies here*/)
      )
    }
    

    core/build.sbt

    name := "core"
    
    CommonBuild.settings
    
    unmanagedResourceDirectories in Compile += baseDirectory.value / "src" / "main" / "resources"
    
    unmanagedResourceDirectories in Test += baseDirectory.value / "src" / "test" / "resources"
    
    publishMavenStyle := true
    
    publishArtifact in Test := true
    

    my_app/build.sbt

    CommonBuild.settings
    
    lazy val my_app =
      (project in file(".")).
        enablePlugins(PlayScala)
        .aggregate(core)
        .dependsOn(core % "test->test;compile->compile")
    
    lazy val core = project
    
    name := "my-app"
    
    routesGenerator := InjectedRoutesGenerator
    

    如果我没有publishpublishLocal core工件,my_app不会选择core模块进行编译并抛出一堆编译错误。

    如何确保激活器和IntelliJ IDEA都使用核心模块本身作为依赖而不是由它产生的工件?

0 个答案:

没有答案