3
我試圖建立多模塊的開發環境與播放2.2.2和0.13.1 SBT播放2.2.2 SBT分項目和Scala
我的項目結構如下:
myProject
└ build.sbt
└ app - this code works perfect
└ modules
└ testModule
└ build.sbt
└ src
└ main
└ scala - here I have simple object Foo with method which returns string
└ test
└ scala - here is Spec2 test for Foo object with JUnitRunner
└ test - here is Spec2 tests for app and these tests also works fine
build.sbt在根目錄中包含:在模塊
import play.Project._
name := "FooBar"
version := "1.0"
playScalaSettings
lazy val main = project.in(file("."))
.dependsOn(testModule).aggregate(testModule)
lazy val testModule = project.in(file("modules/testModule"))
build.sbt只包含:
import play.Project._
name := "FooBar-module"
playScalaSettings
當我試圖使用testModule中的代碼時,編譯器告訴我它甚至無法從該模塊中找到包。同時在運行測試中,我得到了
沒有測試,以testModule /試運行:測試
但如果我寫testModule無效代碼,我將開始從該模塊出現錯誤,所以模塊絕對編譯。
這裏有什麼問題? SBT配置看起來正確
是的,我改變了目錄,在playScalaSettings,一切工作 - 測試和應用程序!非常感謝! – ViLPy
關於.aggregate(testModule):如果在主項目上測試的情況下沒有聚合,測試將不會在子項目上運行 – ViLPy
@ViLPy:哦,沒有意識到。我會從問題中刪除該部分。很高興我能幫上忙。 –