enso/project/RecompileParser.scala
Ara Adkins 746521f8b2
Bump SBT and Scalafmt (#1203)
Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
Co-authored-by: Dmitry Bushev <bushevdv@gmail.com>
2020-10-22 16:12:28 +02:00

24 lines
675 B
Scala

import sbt._
import sbt.Keys._
import sbtcrossproject.CrossProject
import sbtcrossproject.CrossPlugin.autoImport._
object RecompileParser {
/** Ensures that the project is recompiled whenever the project from
* `syntaxDefinition` is changed. Should be attached to the `compile` task as
* a dependency.
*/
def run(syntaxDefinition: CrossProject) =
Def.taskDyn {
val parserCompile =
(syntaxDefinition.jvm / Compile / compileIncremental).value
if (parserCompile.hasModified) {
Def.task {
streams.value.log.info("Parser changed, forcing recompilation.")
clean.value
}
} else Def.task {}
}
}