scalasbt-webincremental-compiler

SBT-web incremental compilation with file dependencies


I'm trying to write an set-web plugin which compiles sass files. I'm adhering to the convention that files with names starting with an "_" are not compiled directly, but they can be included in other files. I attempted to do this by using the following file filter:

excludeFilter in sassify := HiddenFileFilter || "_*"

The modified source files are then compiled as:

val results = incremental.syncIncremental((streams in Assets).value.cacheDirectory / "run", sources) {
  modifiedSources: Seq[File] =>
    if (modifiedSources)
      streams.value.log.info(s"Sass compiling on ${modifiedSources} source(s)")

    val compilationResults: Map[File, (OpResult, Seq[Problem])] = modifiedSources
      .map(inputFile =>
        inputFile -> doCompile(inputFile)
      ).toMap

    if (compilationResults.nonEmpty)
      streams.value.log.info(s"Sass compilation done. Compiled ${compilationResults.size} file(s).")

    (compilationResults.mapValues(_._1), compilationProblems.values.flatMap(_._2))
}

Note that when the doCompile function returns an OpSuccess, I make sure that any included file is included in the readFiles parameter.

Unfortunately, when one of the imported files (starting with an _) is changed, the including file is not recompiled. Any idea how I could fix this?

I'm using scala 2.11.7 and sbt-web 1.2.2


Solution

  • Turns out, the path to the included files was malformed. After fixing this, incremental compilation of included files worked perfectly.