我正在使用 OTHER_HOME
环境变量指向不同的 SBT 项目目录。我打算将外部目录放在 maven 存储库中或通过 github.com#tag 项目引用,但现在我想向 Play 项目添加基于文件的依赖项。
我已经在 Build.scala
工作了风格:
val otherProjectDir = Option(System.getenv("OTHER_HOME"))
.getOrElse("Set environment OTHER_HOME to your 'other' git clone")
// take the core sublibrary from other project
val otherCore = ProjectRef(file(otherProjectDir), "core")
val main = play.Project(appName, appVersion, appDependencies)
.dependsOn(otherCore)
我想切换到
build.sbt
,但我不知道如何做到这一点。请指教。
最佳答案
看起来 play 有办法操纵他们的“监视服务”(监视文件的变化)。尝试将此添加到 build.sbt
使重新加载等待一个小时(或您想要的时间):
PlayKeys.fileWatchService := play.runsupport.FileWatchService.sbt(3600000)
见这里:https://www.playframework.com/documentation/2.4.x/Migration24#playWatchService-renamed
如果您想完全禁用它,您应该能够创建自己的
FileWatchService
实例。并设置上面的键以使用您的自定义观察器(并使您的服务不执行任何操作)。就像是:PlayKeys.fileWatchService := new FileWatchService {
def watch(filesToWatch: Seq[File], onChange: () => Unit): FileWatcher =
new FileWatcher {
def stop(): Unit = ()
}
}
请注意,我还没有测试过这个片段,但你可以查看
FileWatchService
的来源。引用:https://github.com/playframework/playframework/blob/master/framework/src/run-support/src/main/scala/play/runsupport/FileWatchService.scala#L23
关于scala - 在 Play 中使用 System.getenv 在 build.sbt 中设置 ProjectRef?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22176010/