2014-01-10 43 views
3

我有以下Build項目定義,設置了多項目構建:使用SBT中的ProjectRef無法在多項目構建中「投射gostats」?

import sbt._ 
import Keys._ 

object Build extends Build { 
    lazy val gostats = ProjectRef(id = "gostats", base = file("modules/gostats_0.1")) 

    lazy val godeploy = Project(id = "godeploy", base = file(".")) 
    .aggregate(gostats).dependsOn(gostats) 
} 

編譯沒有問題,但我不能運行在SBT控制檯project gostats

如果我將ProjectRef更改爲Projectgostats,gostats不再編譯,因爲SBT在此情況下忽略了我的項目設置。

我該如何獲得兩全其美?

回答

2

如果您使用SBT 0.13.x,您可以在build.sbt中定義Multi-Project Builds。以下是您的對象Build之後的godeploygostats

lazy val godeploy = project in file(".") aggregate gostats dependsOn gostats 

lazy val gostats = project in file("modules")/"gostats_0.1" 

有了這個,我可以project項目沒有錯誤。

[godeploy]> projects 
[info] In file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/ 
[info] * godeploy 
[info]  gostats 
[godeploy]> project gostats 
[info] Set current project to gostats (in build file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/) 
[gostats]> projects 
[info] In file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/ 
[info]  godeploy 
[info] * gostats 
[gostats]> compile 
[info] Updating {file:/Users/jacek/sandbox/so/multi-0.13.1-project-ref/}gostats... 
[info] Resolving org.fusesource.jansi#jansi;1.4 ... 
[info] Done updating. 
[success] Total time: 0 s, completed Jan 11, 2014 2:23:34 PM 

SBT也創造了該項目的目錄結構,我,我只能用build.sbtproject/build.properties文件開始。

jacek:~/sandbox/so/multi-0.13.1-project-ref 
$ tree -L 2 
. 
├── build.sbt 
├── modules 
│   └── gostats_0.1 
└── project 
    └── build.properties 

3 directories, 2 files 
+0

謝謝。這非常有幫助。 我不認爲要切換到使用'build.sbt'。現在我的依賴關係正常工作,我可以切換項目。 – user3180279