mirror of https://github.com/sbt/sbt.git
Reuse thread pool from `FileCache`
This commit is contained in:
parent
78e61fec0f
commit
5f595b23a4
|
|
@ -2,7 +2,6 @@ package lmcoursier.internal
|
|||
|
||||
import java.io.File
|
||||
|
||||
import coursier.cache.internal.ThreadUtil
|
||||
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
||||
import coursier.core.Type
|
||||
import coursier.util.Artifact
|
||||
|
|
@ -38,53 +37,50 @@ object ArtifactsRun {
|
|||
else
|
||||
""
|
||||
|
||||
ThreadUtil.withFixedThreadPool(params.parallel) { pool =>
|
||||
|
||||
coursier.Artifacts()
|
||||
.withResolutions(params.resolutions)
|
||||
.withArtifactTypes(Set(Type.all))
|
||||
.withClassifiers(params.classifiers.getOrElse(Nil).toSet)
|
||||
.withClasspathOrder(params.classpathOrder)
|
||||
.addExtraArtifacts { l =>
|
||||
if (params.includeSignatures)
|
||||
l.flatMap(_._3.extra.get("sig").toSeq)
|
||||
else
|
||||
Nil
|
||||
}
|
||||
.addTransformArtifacts { artifacts =>
|
||||
if (params.missingOk)
|
||||
artifacts.map {
|
||||
case (dependency, publication, artifact) =>
|
||||
(dependency, publication, artifact.withOptional(true))
|
||||
coursier.Artifacts()
|
||||
.withResolutions(params.resolutions)
|
||||
.withArtifactTypes(Set(Type.all))
|
||||
.withClassifiers(params.classifiers.getOrElse(Nil).toSet)
|
||||
.withClasspathOrder(params.classpathOrder)
|
||||
.addExtraArtifacts { l =>
|
||||
if (params.includeSignatures)
|
||||
l.flatMap(_._3.extra.get("sig").toSeq)
|
||||
else
|
||||
Nil
|
||||
}
|
||||
.addTransformArtifacts { artifacts =>
|
||||
if (params.missingOk)
|
||||
artifacts.map {
|
||||
case (dependency, publication, artifact) =>
|
||||
(dependency, publication, artifact.withOptional(true))
|
||||
}
|
||||
else
|
||||
artifacts
|
||||
}
|
||||
.withCache(
|
||||
params
|
||||
.cache
|
||||
.withLogger(
|
||||
params.loggerOpt.getOrElse {
|
||||
RefreshLogger.create(
|
||||
if (RefreshLogger.defaultFallbackMode)
|
||||
new FallbackRefreshDisplay()
|
||||
else
|
||||
ProgressBarRefreshDisplay.create(
|
||||
if (printOptionalMessage) log.info(artifactInitialMessage),
|
||||
if (printOptionalMessage || verbosityLevel >= 2)
|
||||
log.info(
|
||||
s"Fetched artifacts of ${params.projectName}" +
|
||||
(if (params.sbtClassifiers) " (sbt classifiers)" else "")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
else
|
||||
artifacts
|
||||
}
|
||||
.withCache(
|
||||
params
|
||||
.cache
|
||||
.withPool(pool)
|
||||
.withLogger(
|
||||
params.loggerOpt.getOrElse {
|
||||
RefreshLogger.create(
|
||||
if (RefreshLogger.defaultFallbackMode)
|
||||
new FallbackRefreshDisplay()
|
||||
else
|
||||
ProgressBarRefreshDisplay.create(
|
||||
if (printOptionalMessage) log.info(artifactInitialMessage),
|
||||
if (printOptionalMessage || verbosityLevel >= 2)
|
||||
log.info(
|
||||
s"Fetched artifacts of ${params.projectName}" +
|
||||
(if (params.sbtClassifiers) " (sbt classifiers)" else "")
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
.eitherResult()
|
||||
.map(_.fullDetailedArtifacts) // FIXME Misses extraArtifacts, that we don't use for now though
|
||||
}
|
||||
)
|
||||
)
|
||||
.eitherResult()
|
||||
.map(_.fullDetailedArtifacts) // FIXME Misses extraArtifacts, that we don't use for now though
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package lmcoursier.internal
|
||||
|
||||
import coursier.cache.internal.ThreadUtil
|
||||
import coursier.{Resolution, Resolve}
|
||||
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
||||
import coursier.core._
|
||||
|
|
@ -80,51 +79,47 @@ object ResolutionRun {
|
|||
if (verbosityLevel >= 2)
|
||||
log.info(initialMessage)
|
||||
|
||||
ThreadUtil.withFixedThreadPool(params.parallel) { pool =>
|
||||
|
||||
Resolve()
|
||||
// re-using various caches from a resolution of a configuration we extend
|
||||
.withInitialResolution(startingResolutionOpt)
|
||||
.withDependencies(
|
||||
params.dependencies.collect {
|
||||
case (config, dep) if configs(config) =>
|
||||
dep
|
||||
}
|
||||
)
|
||||
.withRepositories(repositories)
|
||||
.withResolutionParams(
|
||||
params
|
||||
.params
|
||||
.addForceVersion((if (isSandboxConfig) Nil else params.interProjectDependencies.map(_.moduleVersion)): _*)
|
||||
.withForceScalaVersion(params.autoScalaLibOpt.nonEmpty)
|
||||
.withScalaVersionOpt(params.autoScalaLibOpt.map(_._2))
|
||||
.withTypelevel(params.params.typelevel)
|
||||
.withRules(rules)
|
||||
)
|
||||
.withCache(
|
||||
params
|
||||
.cache
|
||||
.withPool(pool)
|
||||
.withLogger(
|
||||
params.loggerOpt.getOrElse {
|
||||
RefreshLogger.create(
|
||||
if (RefreshLogger.defaultFallbackMode)
|
||||
new FallbackRefreshDisplay()
|
||||
else
|
||||
ProgressBarRefreshDisplay.create(
|
||||
if (printOptionalMessage) log.info(initialMessage),
|
||||
if (printOptionalMessage || verbosityLevel >= 2)
|
||||
log.info(s"Resolved ${params.projectName} dependencies")
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
.either() match {
|
||||
case Left(err) if params.missingOk => Right(err.resolution)
|
||||
case others => others
|
||||
Resolve()
|
||||
// re-using various caches from a resolution of a configuration we extend
|
||||
.withInitialResolution(startingResolutionOpt)
|
||||
.withDependencies(
|
||||
params.dependencies.collect {
|
||||
case (config, dep) if configs(config) =>
|
||||
dep
|
||||
}
|
||||
}
|
||||
)
|
||||
.withRepositories(repositories)
|
||||
.withResolutionParams(
|
||||
params
|
||||
.params
|
||||
.addForceVersion((if (isSandboxConfig) Nil else params.interProjectDependencies.map(_.moduleVersion)): _*)
|
||||
.withForceScalaVersion(params.autoScalaLibOpt.nonEmpty)
|
||||
.withScalaVersionOpt(params.autoScalaLibOpt.map(_._2))
|
||||
.withTypelevel(params.params.typelevel)
|
||||
.withRules(rules)
|
||||
)
|
||||
.withCache(
|
||||
params
|
||||
.cache
|
||||
.withLogger(
|
||||
params.loggerOpt.getOrElse {
|
||||
RefreshLogger.create(
|
||||
if (RefreshLogger.defaultFallbackMode)
|
||||
new FallbackRefreshDisplay()
|
||||
else
|
||||
ProgressBarRefreshDisplay.create(
|
||||
if (printOptionalMessage) log.info(initialMessage),
|
||||
if (printOptionalMessage || verbosityLevel >= 2)
|
||||
log.info(s"Resolved ${params.projectName} dependencies")
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
.either() match {
|
||||
case Left(err) if params.missingOk => Right(err.resolution)
|
||||
case others => others
|
||||
}
|
||||
}
|
||||
|
||||
def resolutions(
|
||||
|
|
|
|||
Loading…
Reference in New Issue