Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.4.x] onLoad now runs with correct FileTreeRepository and CacheStoreFactory #6191

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions main/src/main/scala/sbt/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -940,13 +940,17 @@ object BuiltinCommands {

val session = Load.initialSession(structure, eval, s0)
SessionSettings.checkSession(session, s2)
val s3 = addCacheStoreFactoryFactory(Project.setProject(session, structure, s2))
val s3 = Project.setProject(
session,
structure,
s2,
st => setupGlobalFileTreeRepository(addCacheStoreFactoryFactory(st))
)
val s4 = s3.put(Keys.useLog4J.key, Project.extract(s3).get(Keys.useLog4J))
val s5 = setupGlobalFileTreeRepository(s4)
// This is a workaround for the console task in dotty which uses the classloader cache.
// We need to override the top loader in that case so that it gets the forked jline.
s5.extendedClassLoaderCache.setParent(Project.extract(s5).get(Keys.scalaInstanceTopLoader))
addSuperShellParams(CheckBuildSources.init(LintUnused.lintUnusedFunc(s5)))
s4.extendedClassLoaderCache.setParent(Project.extract(s4).get(Keys.scalaInstanceTopLoader))
addSuperShellParams(CheckBuildSources.init(LintUnused.lintUnusedFunc(s4)))
}

private val setupGlobalFileTreeRepository: State => State = { state =>
Expand Down
12 changes: 10 additions & 2 deletions main/src/main/scala/sbt/Project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,15 @@ object Project extends ProjectExtra {
previousOnUnload(s.runExitHooks())
}

def setProject(session: SessionSettings, structure: BuildStructure, s: State): State = {
def setProject(session: SessionSettings, structure: BuildStructure, s: State): State =
setProject(session, structure, s, identity)

def setProject(
session: SessionSettings,
structure: BuildStructure,
s: State,
preOnLoad: State => State
): State = {
val unloaded = runUnloadHooks(s)
val (onLoad, onUnload) = getHooks(structure.data)
val newAttrs = unloaded.attributes
Expand All @@ -488,7 +496,7 @@ object Project extends ProjectExtra {
val newState = unloaded.copy(attributes = newAttrs)
// TODO: Fix this
onLoad(
updateCurrent(newState) /*LogManager.setGlobalLogLevels(updateCurrent(newState), structure.data)*/
preOnLoad(updateCurrent(newState)) /*LogManager.setGlobalLogLevels(updateCurrent(newState), structure.data)*/
)
}

Expand Down