正在使用Play! 2.0與和我有一個關於構建系統的問題。我有一個聚合多個項目,我有一個共享模塊,其中包含靜態文件和一些.less文件被編譯成一個CSS。重複使用SBT設計的多項目設置
我怎樣才能靜態文件,以及編譯樣式表的輸出複製到其他項目?我試圖自己理解,但看起來,雖然我可以輕鬆地將項目應用於某個設置,但我無法從其他項目中檢索到該設置。
我看了看Play! 2.0鍵
val playAssetsDirectories = SettingKey[Seq[File]]("play-assets-directories")
val incrementalAssetsCompilation = SettingKey[Boolean]("play-incremental-assets-compilation")
val playExternalAssets = SettingKey[Seq[(File, File => PathFinder, String)]]("play-external-assets")
但我不知道如何使用這些信息來修改我的構建文件。
object ApplicationBuild extends Build {
val appName = "Website"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
)
val common = PlayProject(
appName + "-common", appVersion, path = file("modules/common"),mainLang=SCALA,
lessEntryPoints <<= baseDirectory(_/"app"/"assets"/"stylesheets" ** "bootstrap.less")
)
val website = PlayProject(
appName + "-website", appVersion, path = file("modules/website"),mainLang=SCALA,
).dependsOn(common)
val adminArea = PlayProject(
appName + "-admin", appVersion, path = file("modules/admin"),mainLang=SCALA,
).dependsOn(common)
val main = PlayProject(
appName, appVersion,appDependencies,mainLang=SCALA
).dependsOn(
website, adminArea
)
}
我基本上是想怎麼說這是:
website.playExternalAssets += common.playAssetsDirectory(IncludingCompiled)
但這顯然是不合法的。
其實我已經瞭解多一點,和下面的代碼似乎是正確的:
val website = PlayProject(
appName + "-website", appVersion, path = file("modules/website"),mainLang=SCALA
).dependsOn(common).settings(playExternalAssets <<= common.playAssetsDirectory(IncludingCompile))
除了common.playAssetsDirectory不起作用:
[info] Loading project definition from G:\project1\project [error] G:\project1\project\Build.scala:26: value playAssetsDirectory is not a member of sbt.Project [error] ).dependsOn(common).settings(playExternalAssets <<= common.playA ssetsDirectory(IncludingCompile)) [error] ^[error] one error found [error] {file:/G:/project1/project/}default-436781/compile:compile: Compilati on failed
它看起來像這裏的問題是鍵是恆定的值而不是項目的屬性。其實,關鍵是在PlayKeys常量定義全局值,所以我真的需要指定範圍,但我不知道
啊,現在我明白你在做什麼了! –
您引用了錯誤消息,而不是將其粘貼爲代碼。這就破壞了這個'^'卡雷的位置。猜測,刪除'common.'。 –
爲我解釋了鑰匙必須限定這並不因爲工作... :( – Edmondo1984