include lintBuild as part of reload command

This commit is contained in:
Eugene Yokota 2019-10-03 23:27:07 -04:00
parent 765c451832
commit 3a96ffa2cf
2 changed files with 18 additions and 5 deletions

View File

@ -833,10 +833,10 @@ object BuiltinCommands {
checkSBTVersionChanged(s0)
val (s1, base) = Project.loadAction(SessionVar.clear(s0), action)
IO.createDirectory(base)
val s = if (s1 has Keys.stateCompilerCache) s1 else registerCompilerCache(s1)
val s2 = if (s1 has Keys.stateCompilerCache) s1 else registerCompilerCache(s1)
val (eval, structure) =
try Load.defaultLoad(s, base, s.log, Project.inPluginProject(s), Project.extraBuilds(s))
try Load.defaultLoad(s2, base, s2.log, Project.inPluginProject(s2), Project.extraBuilds(s2))
catch {
case ex: compiler.EvalException =>
s0.log.debug(ex.getMessage)
@ -846,12 +846,13 @@ object BuiltinCommands {
}
val session = Load.initialSession(structure, eval, s0)
SessionSettings.checkSession(session, s)
addCacheStoreFactoryFactory(
SessionSettings.checkSession(session, s2)
val s3 = addCacheStoreFactoryFactory(
Project
.setProject(session, structure, s)
.setProject(session, structure, s2)
.put(sbt.nio.Keys.hasCheckedMetaBuild, new AtomicBoolean(false))
)
LintBuild.lintBuildFunc(s3)
}
private val addCacheStoreFactoryFactory: State => State = (s: State) => {

View File

@ -38,6 +38,7 @@ object LintBuild {
lintBuild := lintBuildTask.evaluated,
)
// input task version of the lintBuild
def lintBuildTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
val _ = Def.spaceDelimited().parsed // not used yet
val state = Keys.state.value
@ -49,6 +50,17 @@ object LintBuild {
else lintResultLines(result) foreach { log.warn(_) }
}
// function version of the lintBuild, based on just state
def lintBuildFunc(s: State): State = {
val log = s.log
val extracted = Project.extract(s)
val includeKeys = extracted.get(includeLintKeys in Global) map { _.scopedKey.key.label }
val excludeKeys = extracted.get(excludeLintKeys in Global) map { _.scopedKey.key.label }
val result = lint(s, includeKeys, excludeKeys)
lintResultLines(result) foreach { log.warn(_) }
s
}
def lintResultLines(
result: Seq[(ScopedKey[_], String, Vector[SourcePosition])]
): Vector[String] = {