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,90 +1,83 @@
|
||||||
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(
|
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
||||||
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 artifactInitialMessage =
|
||||||
|
if (verbosityLevel >= 0)
|
||||||
|
s"Fetching artifacts of ${params.projectName}" +
|
||||||
|
(if (params.sbtClassifiers) " (sbt classifiers)" else "")
|
||||||
|
else
|
||||||
|
""
|
||||||
|
|
||||||
val artifactInitialMessage =
|
// Ensuring only one resolution / artifact fetching runs at a time when the logger
|
||||||
if (verbosityLevel >= 0)
|
// may rely on progress bars, as two progress bar loggers can't display stuff at the
|
||||||
s"Fetching artifacts of ${params.projectName}" +
|
// same time.
|
||||||
(if (params.sbtClassifiers) " (sbt classifiers)" else "")
|
val needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode
|
||||||
|
|
||||||
|
val coursierLogger = params.loggerOpt.getOrElse {
|
||||||
|
RefreshLogger.create(
|
||||||
|
if (RefreshLogger.defaultFallbackMode)
|
||||||
|
new FallbackRefreshDisplay()
|
||||||
else
|
else
|
||||||
""
|
ProgressBarRefreshDisplay.create(
|
||||||
|
if (printOptionalMessage) log.info(artifactInitialMessage),
|
||||||
ThreadUtil.withFixedThreadPool(params.parallel) { pool =>
|
if (printOptionalMessage || verbosityLevel >= 2)
|
||||||
|
log.info(
|
||||||
coursier.Artifacts()
|
s"Fetched artifacts of ${params.projectName}" +
|
||||||
.withResolutions(params.resolutions)
|
(if (params.sbtClassifiers) " (sbt classifiers)" else "")
|
||||||
.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
|
|
||||||
.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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
.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(coursierLogger))
|
||||||
|
.eitherResult()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,51 +79,47 @@ object ResolutionRun {
|
||||||
if (verbosityLevel >= 2)
|
if (verbosityLevel >= 2)
|
||||||
log.info(initialMessage)
|
log.info(initialMessage)
|
||||||
|
|
||||||
ThreadUtil.withFixedThreadPool(params.parallel) { pool =>
|
Resolve()
|
||||||
|
// re-using various caches from a resolution of a configuration we extend
|
||||||
Resolve()
|
.withInitialResolution(startingResolutionOpt)
|
||||||
// re-using various caches from a resolution of a configuration we extend
|
.withDependencies(
|
||||||
.withInitialResolution(startingResolutionOpt)
|
params.dependencies.collect {
|
||||||
.withDependencies(
|
case (config, dep) if configs(config) =>
|
||||||
params.dependencies.collect {
|
dep
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
.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(
|
def resolutions(
|
||||||
|
|
@ -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