From 3a96ffa2cfad6fc823e8db9f25342182c8bf4b7d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 3 Oct 2019 23:27:07 -0400 Subject: [PATCH] include lintBuild as part of reload command --- main/src/main/scala/sbt/Main.scala | 11 ++++++----- main/src/main/scala/sbt/internal/LintBuild.scala | 12 ++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index ce1d29ccf..b3a3bdcce 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -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) => { diff --git a/main/src/main/scala/sbt/internal/LintBuild.scala b/main/src/main/scala/sbt/internal/LintBuild.scala index ad18e8fa3..0151ccfbf 100644 --- a/main/src/main/scala/sbt/internal/LintBuild.scala +++ b/main/src/main/scala/sbt/internal/LintBuild.scala @@ -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] = {