5

I'm using an OTHER_HOME environment variable to point to a different SBT project directory. I'm going to put the external directory in maven repository or via a github.com#tag project reference, but for now I'd like to add a file-based dependency to a Play project.

I've got this working in Build.scala style:

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)

I'd like to switch to build.sbt, but I have no clue how to do this. Please advise.

Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
Jaap
  • 2,802
  • 2
  • 26
  • 48
  • Te be clear, it works, but I'm running into problems with subprojects. – Jaap Mar 04 '14 at 15:25
  • Just copy and paste it to `build.sbt` with no changes. Did you try it out? – Jacek Laskowski Mar 04 '14 at 23:18
  • What issues are you running into? It's hard to tell how to fix things without knowing what the symptoms are. – jsuereth Aug 01 '14 at 14:38
  • It's unclear how build.sbt works, is it a Scala file? It doesn't contain imports and it is very picky about line endings, so for me copy and pasting Build.scala code into build.sbt seems wrong – Jaap Aug 03 '14 at 11:28

1 Answers1

0

looks like play has a way to manipulate their "watch service" (which watches files for changes). try adding this to build.sbt to make reloading wait an hour (or however long you want):

PlayKeys.fileWatchService := play.runsupport.FileWatchService.sbt(3600000)

see here: https://www.playframework.com/documentation/2.4.x/Migration24#playWatchService-renamed

if you want to completely disable it, you should be able to create your own instance of a FileWatchService and set the key above to use your custom watcher (and make your service do nothing). something like:

PlayKeys.fileWatchService := new FileWatchService {
  def watch(filesToWatch: Seq[File], onChange: () => Unit): FileWatcher = 
    new FileWatcher {
      def stop(): Unit = ()
    }
}

note that i haven't tested this snippet, but you can look at the source of FileWatchService here for reference: https://github.com/playframework/playframework/blob/master/framework/src/run-support/src/main/scala/play/runsupport/FileWatchService.scala#L23

handler
  • 1,433
  • 11
  • 10