2020-07-01 14:21:13 +03:00
|
|
|
import sbt._
|
|
|
|
import sbt.Keys._
|
|
|
|
|
|
|
|
object RecompileParser {
|
|
|
|
|
2020-10-22 17:12:28 +03:00
|
|
|
/** Ensures that the project is recompiled whenever the project from
|
2020-07-01 14:21:13 +03:00
|
|
|
* `syntaxDefinition` is changed. Should be attached to the `compile` task as
|
|
|
|
* a dependency.
|
|
|
|
*/
|
2023-03-15 18:43:51 +03:00
|
|
|
def run(syntaxDefinition: Project) =
|
2020-07-01 14:21:13 +03:00
|
|
|
Def.taskDyn {
|
|
|
|
val parserCompile =
|
2023-03-15 18:43:51 +03:00
|
|
|
(syntaxDefinition / Compile / compileIncremental).value
|
2020-07-01 14:21:13 +03:00
|
|
|
if (parserCompile.hasModified) {
|
|
|
|
Def.task {
|
|
|
|
streams.value.log.info("Parser changed, forcing recompilation.")
|
|
|
|
clean.value
|
|
|
|
}
|
|
|
|
} else Def.task {}
|
|
|
|
}
|
|
|
|
}
|