mirror of https://github.com/sbt/sbt.git
commit
edb1cfa20c
|
|
@ -222,9 +222,9 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
||||||
val e = for {
|
val e = for {
|
||||||
resolutions <- ResolutionRun.resolutions(resolutionParams, verbosityLevel, log)
|
resolutions <- ResolutionRun.resolutions(resolutionParams, verbosityLevel, log)
|
||||||
artifactsParams0 = artifactsParams(resolutions)
|
artifactsParams0 = artifactsParams(resolutions)
|
||||||
artifacts <- ArtifactsRun.artifactsResult(artifactsParams0, verbosityLevel, log)
|
artifacts <- ArtifactsRun(artifactsParams0, verbosityLevel, log)
|
||||||
} yield {
|
} yield {
|
||||||
val updateParams0 = updateParams(resolutions, artifacts)
|
val updateParams0 = updateParams(resolutions, artifacts.fullDetailedArtifacts)
|
||||||
UpdateRun.update(updateParams0, verbosityLevel, log)
|
UpdateRun.update(updateParams0, verbosityLevel, log)
|
||||||
}
|
}
|
||||||
e.left.map(unresolvedWarningOrThrow(uwconfig, _))
|
e.left.map(unresolvedWarningOrThrow(uwconfig, _))
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,19 @@
|
||||||
package lmcoursier.internal
|
package lmcoursier.internal
|
||||||
|
|
||||||
import java.io.File
|
import coursier.Artifacts
|
||||||
|
import coursier.cache.CacheLogger
|
||||||
import coursier.cache.internal.ThreadUtil
|
|
||||||
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
||||||
import coursier.core.Type
|
import coursier.core.Type
|
||||||
import coursier.util.Artifact
|
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
import coursier.core.Dependency
|
|
||||||
import coursier.core.Publication
|
|
||||||
|
|
||||||
// private[coursier]
|
// private[lmcoursier]
|
||||||
object ArtifactsRun {
|
object ArtifactsRun {
|
||||||
|
|
||||||
def artifacts(
|
def apply(
|
||||||
params: ArtifactsParams,
|
params: ArtifactsParams,
|
||||||
verbosityLevel: Int,
|
verbosityLevel: Int,
|
||||||
log: Logger
|
log: Logger
|
||||||
): Either[coursier.error.FetchError, Map[Artifact, File]] =
|
): Either[coursier.error.FetchError, Artifacts.Result] = {
|
||||||
artifactsResult(params, verbosityLevel, log).map(_.collect { case (_, _, a, Some(f)) => (a, f) }.toMap)
|
|
||||||
|
|
||||||
def artifactsResult(
|
|
||||||
params: ArtifactsParams,
|
|
||||||
verbosityLevel: Int,
|
|
||||||
log: Logger
|
|
||||||
): Either[coursier.error.FetchError, Seq[(Dependency, Publication, Artifact, Option[File])]] =
|
|
||||||
// let's update only one module at once, for a better output
|
|
||||||
// Downloads are already parallel, no need to parallelize further anyway
|
|
||||||
Lock.lock.synchronized {
|
|
||||||
|
|
||||||
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
||||||
|
|
||||||
|
|
@ -38,8 +24,39 @@ object ArtifactsRun {
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
|
|
||||||
ThreadUtil.withFixedThreadPool(params.parallel) { pool =>
|
// Ensuring only one resolution / artifact fetching runs at a time when the logger
|
||||||
|
// may rely on progress bars, as two progress bar loggers can't display stuff at the
|
||||||
|
// same time.
|
||||||
|
val needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode
|
||||||
|
|
||||||
|
val coursierLogger = 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 "")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needsLock)
|
||||||
|
Lock.lock.synchronized {
|
||||||
|
result(params, coursierLogger)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result(params, coursierLogger)
|
||||||
|
}
|
||||||
|
|
||||||
|
private def result(
|
||||||
|
params: ArtifactsParams,
|
||||||
|
coursierLogger: CacheLogger
|
||||||
|
): Either[coursier.error.FetchError, Artifacts.Result] =
|
||||||
coursier.Artifacts()
|
coursier.Artifacts()
|
||||||
.withResolutions(params.resolutions)
|
.withResolutions(params.resolutions)
|
||||||
.withArtifactTypes(Set(Type.all))
|
.withArtifactTypes(Set(Type.all))
|
||||||
|
|
@ -60,31 +77,7 @@ object ArtifactsRun {
|
||||||
else
|
else
|
||||||
artifacts
|
artifacts
|
||||||
}
|
}
|
||||||
.withCache(
|
.withCache(params.cache.withLogger(coursierLogger))
|
||||||
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()
|
.eitherResult()
|
||||||
.map(_.fullDetailedArtifacts) // FIXME Misses extraArtifacts, that we don't use for now though
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package lmcoursier.internal
|
package lmcoursier.internal
|
||||||
|
|
||||||
import coursier.cache.internal.ThreadUtil
|
|
||||||
import coursier.{Resolution, Resolve}
|
import coursier.{Resolution, Resolve}
|
||||||
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
||||||
import coursier.core._
|
import coursier.core._
|
||||||
|
|
@ -80,8 +79,6 @@ object ResolutionRun {
|
||||||
if (verbosityLevel >= 2)
|
if (verbosityLevel >= 2)
|
||||||
log.info(initialMessage)
|
log.info(initialMessage)
|
||||||
|
|
||||||
ThreadUtil.withFixedThreadPool(params.parallel) { pool =>
|
|
||||||
|
|
||||||
Resolve()
|
Resolve()
|
||||||
// re-using various caches from a resolution of a configuration we extend
|
// re-using various caches from a resolution of a configuration we extend
|
||||||
.withInitialResolution(startingResolutionOpt)
|
.withInitialResolution(startingResolutionOpt)
|
||||||
|
|
@ -104,7 +101,6 @@ object ResolutionRun {
|
||||||
.withCache(
|
.withCache(
|
||||||
params
|
params
|
||||||
.cache
|
.cache
|
||||||
.withPool(pool)
|
|
||||||
.withLogger(
|
.withLogger(
|
||||||
params.loggerOpt.getOrElse {
|
params.loggerOpt.getOrElse {
|
||||||
RefreshLogger.create(
|
RefreshLogger.create(
|
||||||
|
|
@ -125,7 +121,6 @@ object ResolutionRun {
|
||||||
case others => others
|
case others => others
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
def resolutions(
|
def resolutions(
|
||||||
params: ResolutionParams,
|
params: ResolutionParams,
|
||||||
|
|
@ -188,7 +183,7 @@ object ResolutionRun {
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
either.map(_ => map.toMap)
|
withSubResolutions.map(_ => map.toMap)
|
||||||
}
|
}
|
||||||
for (res <- resOrError)
|
for (res <- resOrError)
|
||||||
SbtCoursierCache.default.putResolution(params.resolutionKey, res)
|
SbtCoursierCache.default.putResolution(params.resolutionKey, res)
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ object ArtifactsTasks {
|
||||||
missingOk = sbtClassifiers
|
missingOk = sbtClassifiers
|
||||||
)
|
)
|
||||||
|
|
||||||
val resOrError = ArtifactsRun.artifacts(
|
val resOrError = ArtifactsRun(
|
||||||
params,
|
params,
|
||||||
verbosityLevel,
|
verbosityLevel,
|
||||||
log
|
log
|
||||||
|
|
@ -85,7 +85,7 @@ object ArtifactsTasks {
|
||||||
case Left(err) =>
|
case Left(err) =>
|
||||||
throw err
|
throw err
|
||||||
case Right(res0) =>
|
case Right(res0) =>
|
||||||
res0
|
res0.artifacts.toMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue