mirror of https://github.com/sbt/sbt.git
Merge branch 'develop' into meta-reload-check
This commit is contained in:
commit
4158716b9a
|
|
@ -96,5 +96,5 @@ object ClassLoaderLayeringStrategy {
|
|||
/**
|
||||
* Add a layer on top of the ScalaLibrary layer for all of the jar dependencies.
|
||||
*/
|
||||
object AllLibraryJars extends AllLibraryJars
|
||||
case object AllLibraryJars extends AllLibraryJars
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ package sbt
|
|||
|
||||
import java.io.{ File, IOException }
|
||||
import java.net.URI
|
||||
import java.util.concurrent.{ Executors, ForkJoinPool }
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.{ Locale, Properties }
|
||||
|
||||
|
|
@ -96,11 +97,21 @@ object StandardMain {
|
|||
private[sbt] lazy val exchange = new CommandExchange()
|
||||
import scalacache.caffeine._
|
||||
private[sbt] lazy val cache: scalacache.Cache[Any] = CaffeineCache[Any]
|
||||
// The access to the pool should be thread safe because lazy val instantiation is thread safe
|
||||
// and pool is only referenced directly in closeRunnable after the executionContext is sure
|
||||
// to have been instantiated
|
||||
private[this] var pool: Option[ForkJoinPool] = None
|
||||
private[sbt] lazy val executionContext: ExecutionContext = ExecutionContext.fromExecutor({
|
||||
val p = new ForkJoinPool
|
||||
pool = Some(p)
|
||||
p
|
||||
})
|
||||
|
||||
private[this] val closeRunnable = () => {
|
||||
cache.close()(scalacache.modes.sync.mode)
|
||||
cache.close()(scalacache.modes.scalaFuture.mode(ExecutionContext.global))
|
||||
cache.close()(scalacache.modes.scalaFuture.mode(executionContext))
|
||||
exchange.shutdown()
|
||||
pool.foreach(_.shutdownNow())
|
||||
}
|
||||
|
||||
def runManaged(s: State): xsbti.MainResult = {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ private[sbt] object ClassLoaders {
|
|||
}
|
||||
/*
|
||||
* Create a layered classloader. There are up to four layers:
|
||||
* 1) the scala instance class loader
|
||||
* 1) the scala instance class loader (may actually be two layers if scala-reflect is used)
|
||||
* 2) the resource layer
|
||||
* 3) the dependency jars
|
||||
* 4) the rest of the classpath
|
||||
|
|
@ -132,15 +132,21 @@ private[sbt] object ClassLoaders {
|
|||
case _: AllLibraryJars => true
|
||||
case _ => false
|
||||
}
|
||||
val allDependenciesSet = allDependencies.toSet
|
||||
val scalaLibraryLayer = layer(si.libraryJars, interfaceLoader, cache, resources, tmp)
|
||||
val cpFiles = fullCP.map(_._1)
|
||||
|
||||
val scalaReflectJar = allDependencies.find(_.getName == "scala-reflect.jar")
|
||||
val scalaReflectLayer = scalaReflectJar
|
||||
.map { file =>
|
||||
layer(file :: Nil, scalaLibraryLayer, cache, resources, tmp)
|
||||
}
|
||||
.getOrElse(scalaLibraryLayer)
|
||||
|
||||
// layer 2 (resources)
|
||||
val resourceLayer =
|
||||
if (layerDependencies)
|
||||
getResourceLayer(cpFiles, resourceCP, scalaLibraryLayer, cache, resources)
|
||||
else scalaLibraryLayer
|
||||
getResourceLayer(cpFiles, resourceCP, scalaReflectLayer, cache, resources)
|
||||
else scalaReflectLayer
|
||||
|
||||
// layer 3 (optional if in the test config and the runtime layer is not shared)
|
||||
val dependencyLayer =
|
||||
|
|
@ -148,7 +154,10 @@ private[sbt] object ClassLoaders {
|
|||
else resourceLayer
|
||||
|
||||
// layer 4
|
||||
val dynamicClasspath = cpFiles.filterNot(allDependenciesSet ++ si.libraryJars)
|
||||
val filteredSet =
|
||||
if (layerDependencies) allDependencies.toSet ++ si.libraryJars ++ scalaReflectJar
|
||||
else Set(si.libraryJars ++ scalaReflectJar: _*)
|
||||
val dynamicClasspath = cpFiles.filterNot(filteredSet)
|
||||
new LayeredClassLoader(dynamicClasspath, dependencyLayer, resources, tmp)
|
||||
}
|
||||
ClasspathUtilities.filterByClasspath(cpFiles, raw)
|
||||
|
|
|
|||
|
|
@ -93,9 +93,9 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe
|
|||
val workingDirectory: File,
|
||||
val job: BackgroundJob
|
||||
) extends AbstractJobHandle {
|
||||
implicit val executionContext: ExecutionContext = StandardMain.executionContext
|
||||
def humanReadableName: String = job.humanReadableName
|
||||
// EC for onStop handler below
|
||||
import ExecutionContext.Implicits.global
|
||||
job.onStop { () =>
|
||||
// TODO: Fix this
|
||||
// logger.close()
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ private[sbt] object Definition {
|
|||
|
||||
private[sbt] def getAnalyses: Future[Seq[Analysis]] = {
|
||||
import scalacache.modes.scalaFuture._
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
implicit val executionContext: ExecutionContext = StandardMain.executionContext
|
||||
AnalysesAccess
|
||||
.getFrom(StandardMain.cache)
|
||||
.collect { case Some(a) => a }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import sjsonnew.JsonFormat
|
|||
import sjsonnew.shaded.scalajson.ast.unsafe.JValue
|
||||
import sjsonnew.support.scalajson.unsafe.Converter
|
||||
import sbt.protocol.Serialization
|
||||
import sbt.protocol.{ SettingQuery => Q, CompletionParams => CP }
|
||||
import sbt.protocol.{ CompletionParams => CP, SettingQuery => Q }
|
||||
import sbt.internal.langserver.{ CancelRequestParams => CRP }
|
||||
import sbt.internal.protocol._
|
||||
import sbt.internal.protocol.codec._
|
||||
|
|
@ -21,6 +21,8 @@ import sbt.internal.langserver._
|
|||
import sbt.internal.util.ObjectEvent
|
||||
import sbt.util.Logger
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
private[sbt] final case class LangServerError(code: Long, message: String)
|
||||
extends Throwable(message)
|
||||
|
||||
|
|
@ -70,7 +72,7 @@ private[sbt] object LanguageServerProtocol {
|
|||
jsonRpcRespond(InitializeResult(serverCapabilities), Option(r.id))
|
||||
|
||||
case r: JsonRpcRequestMessage if r.method == "textDocument/definition" =>
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
implicit val executionContext: ExecutionContext = StandardMain.executionContext
|
||||
Definition.lspDefinition(json(r), r.id, CommandSource(name), log)
|
||||
()
|
||||
case r: JsonRpcRequestMessage if r.method == "sbt/exec" =>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
> set Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
|
||||
|
||||
-> run
|
||||
|
||||
> set Compile / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
|
||||
|
||||
> test
|
||||
|
||||
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
|
||||
|
|
@ -8,8 +10,14 @@
|
|||
|
||||
> test
|
||||
|
||||
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
|
||||
|
||||
$ copy-file changes/bad.scala src/test/scala/sbt/ScalatestTest.scala
|
||||
|
||||
-> test
|
||||
|
||||
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
|
||||
|
||||
-> test
|
||||
|
||||
> set Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
|
||||
|
||||
-> test
|
||||
|
|
|
|||
Loading…
Reference in New Issue