mirror of https://github.com/sbt/sbt.git
Start to use bits of the high level API of coursier
Its parameters mostly
This commit is contained in:
parent
4226df911d
commit
bc69e0b11a
|
|
@ -1,23 +1,15 @@
|
||||||
package coursier.lmcoursier
|
package coursier.lmcoursier
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
import coursier.cache.CacheLogger
|
import coursier.cache.CacheLogger
|
||||||
import coursier.{Cache, CachePolicy}
|
|
||||||
import coursier.core.{Classifier, Resolution}
|
import coursier.core.{Classifier, Resolution}
|
||||||
|
import coursier.params.CacheParams
|
||||||
import scala.concurrent.duration.Duration
|
|
||||||
|
|
||||||
final case class ArtifactsParams(
|
final case class ArtifactsParams(
|
||||||
classifiers: Option[Seq[Classifier]],
|
classifiers: Option[Seq[Classifier]],
|
||||||
res: Seq[Resolution],
|
res: Seq[Resolution],
|
||||||
includeSignatures: Boolean,
|
includeSignatures: Boolean,
|
||||||
parallelDownloads: Int,
|
|
||||||
createLogger: () => CacheLogger,
|
createLogger: () => CacheLogger,
|
||||||
cache: File,
|
|
||||||
artifactsChecksums: Seq[Option[String]],
|
|
||||||
ttl: Option[Duration],
|
|
||||||
cachePolicies: Seq[CachePolicy],
|
|
||||||
projectName: String,
|
projectName: String,
|
||||||
sbtClassifiers: Boolean
|
sbtClassifiers: Boolean,
|
||||||
|
cacheParams: CacheParams
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -39,18 +39,18 @@ object ArtifactsRun {
|
||||||
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
||||||
|
|
||||||
val artifactFilesOrErrors = try {
|
val artifactFilesOrErrors = try {
|
||||||
pool = Schedulable.fixedThreadPool(params.parallelDownloads)
|
pool = Schedulable.fixedThreadPool(params.cacheParams.parallel)
|
||||||
artifactsLogger = params.createLogger()
|
artifactsLogger = params.createLogger()
|
||||||
|
|
||||||
val artifactFileOrErrorTasks = allArtifacts.toVector.distinct.map { a =>
|
val artifactFileOrErrorTasks = allArtifacts.toVector.distinct.map { a =>
|
||||||
Cache.file[Task](
|
Cache.file[Task](
|
||||||
a,
|
a,
|
||||||
params.cache,
|
params.cacheParams.cacheLocation,
|
||||||
params.cachePolicies,
|
params.cacheParams.cachePolicies,
|
||||||
checksums = params.artifactsChecksums,
|
checksums = params.cacheParams.checksum,
|
||||||
logger = Some(artifactsLogger),
|
logger = Some(artifactsLogger),
|
||||||
pool = pool,
|
pool = pool,
|
||||||
ttl = params.ttl
|
ttl = params.cacheParams.ttl
|
||||||
)
|
)
|
||||||
.run
|
.run
|
||||||
.map((a, _))
|
.map((a, _))
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ package coursier.lmcoursier
|
||||||
|
|
||||||
import java.io.{File, OutputStreamWriter}
|
import java.io.{File, OutputStreamWriter}
|
||||||
|
|
||||||
import _root_.coursier.{Artifact, Cache, CachePolicy, FileError, Organization, Resolution, TermDisplay, organizationString}
|
import _root_.coursier.{Artifact, CachePolicy, FileError, Organization, Resolution, TermDisplay, organizationString}
|
||||||
import _root_.coursier.core.{Classifier, Configuration, ModuleName}
|
import _root_.coursier.core.{Classifier, Configuration, ModuleName}
|
||||||
import _root_.coursier.extra.Typelevel
|
import _root_.coursier.extra.Typelevel
|
||||||
import _root_.coursier.ivy.IvyRepository
|
import _root_.coursier.ivy.IvyRepository
|
||||||
import _root_.coursier.lmcoursier.Inputs.withAuthenticationByHost
|
import _root_.coursier.lmcoursier.Inputs.withAuthenticationByHost
|
||||||
import coursier.cache.CacheDefaults
|
import coursier.cache.CacheDefaults
|
||||||
|
import coursier.params.CacheParams
|
||||||
import sbt.internal.librarymanagement.IvySbt
|
import sbt.internal.librarymanagement.IvySbt
|
||||||
import sbt.librarymanagement._
|
import sbt.librarymanagement._
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
|
|
@ -143,25 +144,27 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
||||||
dependencies = dependencies,
|
dependencies = dependencies,
|
||||||
fallbackDependencies = conf.fallbackDependencies,
|
fallbackDependencies = conf.fallbackDependencies,
|
||||||
configGraphs = configGraphs,
|
configGraphs = configGraphs,
|
||||||
autoScalaLib = conf.autoScalaLibrary,
|
autoScalaLibOpt = if (conf.autoScalaLibrary) Some((so, sv)) else None,
|
||||||
mainRepositories = mainRepositories,
|
mainRepositories = mainRepositories,
|
||||||
parentProjectCache = Map.empty,
|
parentProjectCache = Map.empty,
|
||||||
interProjectDependencies = conf.interProjectDependencies,
|
interProjectDependencies = conf.interProjectDependencies,
|
||||||
internalRepositories = internalRepositories,
|
internalRepositories = internalRepositories,
|
||||||
userEnabledProfiles = conf.mavenProfiles.toSet,
|
|
||||||
userForceVersions = Map.empty,
|
|
||||||
typelevel = typelevel,
|
typelevel = typelevel,
|
||||||
so = so,
|
|
||||||
sv = sv,
|
|
||||||
sbtClassifiers = false,
|
sbtClassifiers = false,
|
||||||
parallelDownloads = conf.parallelDownloads,
|
|
||||||
projectName = projectName,
|
projectName = projectName,
|
||||||
maxIterations = conf.maxIterations,
|
|
||||||
createLogger = createLogger,
|
createLogger = createLogger,
|
||||||
cache = cache,
|
cacheParams = coursier.params.CacheParams(
|
||||||
cachePolicies = cachePolicies,
|
cacheLocation = cache,
|
||||||
ttl = ttl,
|
cachePolicies = cachePolicies,
|
||||||
checksums = checksums
|
ttl = ttl,
|
||||||
|
checksum = checksums,
|
||||||
|
parallel = conf.parallelDownloads
|
||||||
|
),
|
||||||
|
params = coursier.params.ResolutionParams(
|
||||||
|
maxIterations = conf.maxIterations,
|
||||||
|
profiles = conf.mavenProfiles.toSet,
|
||||||
|
forceVersion = Map.empty
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def artifactsParams(resolutions: Map[Set[Configuration], Resolution]) =
|
def artifactsParams(resolutions: Map[Set[Configuration], Resolution]) =
|
||||||
|
|
@ -169,14 +172,16 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
||||||
classifiers = classifiers,
|
classifiers = classifiers,
|
||||||
res = resolutions.values.toSeq,
|
res = resolutions.values.toSeq,
|
||||||
includeSignatures = false,
|
includeSignatures = false,
|
||||||
parallelDownloads = conf.parallelDownloads,
|
|
||||||
createLogger = createLogger,
|
createLogger = createLogger,
|
||||||
cache = cache,
|
|
||||||
artifactsChecksums = checksums,
|
|
||||||
ttl = ttl,
|
|
||||||
cachePolicies = cachePolicies,
|
|
||||||
projectName = projectName,
|
projectName = projectName,
|
||||||
sbtClassifiers = false
|
sbtClassifiers = false,
|
||||||
|
cacheParams = CacheParams(
|
||||||
|
parallel = conf.parallelDownloads,
|
||||||
|
cacheLocation = cache,
|
||||||
|
checksum = checksums,
|
||||||
|
ttl = ttl,
|
||||||
|
cachePolicies = cachePolicies
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val sbtBootJarOverrides = SbtBootJars(
|
val sbtBootJarOverrides = SbtBootJars(
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,31 @@
|
||||||
package coursier.lmcoursier
|
package coursier.lmcoursier
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URL
|
|
||||||
|
|
||||||
import coursier.cache.CacheLogger
|
import coursier.cache.CacheLogger
|
||||||
import coursier.{Cache, CachePolicy, FallbackDependenciesRepository, ProjectCache, Resolution, moduleNameString}
|
import coursier.{FallbackDependenciesRepository, ProjectCache, Resolution, moduleNameString}
|
||||||
import coursier.core._
|
import coursier.core._
|
||||||
import coursier.extra.Typelevel
|
import coursier.extra.Typelevel
|
||||||
import coursier.ivy.PropertiesPattern
|
import coursier.ivy.PropertiesPattern
|
||||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||||
|
|
||||||
import scala.collection.mutable.ArrayBuffer
|
import scala.collection.mutable.ArrayBuffer
|
||||||
import scala.concurrent.duration.Duration
|
|
||||||
|
|
||||||
final case class ResolutionParams(
|
final case class ResolutionParams(
|
||||||
dependencies: Seq[(Configuration, Dependency)],
|
dependencies: Seq[(Configuration, Dependency)],
|
||||||
fallbackDependencies: Seq[FallbackDependency],
|
fallbackDependencies: Seq[FallbackDependency],
|
||||||
configGraphs: Seq[Set[Configuration]],
|
configGraphs: Seq[Set[Configuration]],
|
||||||
autoScalaLib: Boolean,
|
autoScalaLibOpt: Option[(Organization, String)],
|
||||||
mainRepositories: Seq[Repository],
|
mainRepositories: Seq[Repository],
|
||||||
parentProjectCache: ProjectCache,
|
parentProjectCache: ProjectCache,
|
||||||
interProjectDependencies: Seq[Project],
|
interProjectDependencies: Seq[Project],
|
||||||
internalRepositories: Seq[Repository],
|
internalRepositories: Seq[Repository],
|
||||||
userEnabledProfiles: Set[String],
|
|
||||||
userForceVersions: Map[Module, String],
|
|
||||||
typelevel: Boolean,
|
typelevel: Boolean,
|
||||||
so: Organization,
|
|
||||||
sv: String,
|
|
||||||
sbtClassifiers: Boolean,
|
sbtClassifiers: Boolean,
|
||||||
parallelDownloads: Int,
|
|
||||||
projectName: String,
|
projectName: String,
|
||||||
maxIterations: Int,
|
|
||||||
createLogger: () => CacheLogger,
|
createLogger: () => CacheLogger,
|
||||||
cache: File,
|
cacheParams: coursier.params.CacheParams,
|
||||||
cachePolicies: Seq[CachePolicy],
|
params: coursier.params.ResolutionParams
|
||||||
ttl: Option[Duration],
|
|
||||||
checksums: Seq[Option[String]]
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val fallbackDependenciesRepositories =
|
val fallbackDependenciesRepositories =
|
||||||
|
|
@ -79,14 +69,17 @@ final case class ResolutionParams(
|
||||||
},
|
},
|
||||||
filter = noOptionalFilter,
|
filter = noOptionalFilter,
|
||||||
userActivations =
|
userActivations =
|
||||||
if (userEnabledProfiles.isEmpty)
|
if (params.profiles.isEmpty)
|
||||||
None
|
None
|
||||||
else
|
else
|
||||||
Some(userEnabledProfiles.iterator.map(_ -> true).toMap),
|
Some(params.profiles.iterator.map(_ -> true).toMap),
|
||||||
forceVersions =
|
forceVersions =
|
||||||
// order matters here
|
// order matters here
|
||||||
userForceVersions ++
|
params.forceVersion ++
|
||||||
(if (autoScalaLib && (configs(Configuration.compile) || configs(Configuration("scala-tool")))) forcedScalaModules(so, sv) else Map()) ++
|
autoScalaLibOpt
|
||||||
|
.filter(_ => configs(Configuration.compile) || configs(Configuration("scala-tool")))
|
||||||
|
.map { case (so, sv) => forcedScalaModules(so, sv) }
|
||||||
|
.getOrElse(Map.empty) ++
|
||||||
interProjectDependencies.map(_.moduleVersion),
|
interProjectDependencies.map(_.moduleVersion),
|
||||||
projectCache = parentProjectCache,
|
projectCache = parentProjectCache,
|
||||||
mapDependencies = if (typelevel && (configs(Configuration.compile) || configs(Configuration("scala-tool")))) typelevelOrgSwap else None
|
mapDependencies = if (typelevel && (configs(Configuration.compile) || configs(Configuration("scala-tool")))) typelevelOrgSwap else None
|
||||||
|
|
@ -97,7 +90,7 @@ final case class ResolutionParams(
|
||||||
lazy val resolutionKey = SbtCoursierCache.ResolutionKey(
|
lazy val resolutionKey = SbtCoursierCache.ResolutionKey(
|
||||||
dependencies,
|
dependencies,
|
||||||
repositories,
|
repositories,
|
||||||
userEnabledProfiles,
|
params.profiles,
|
||||||
allStartRes,
|
allStartRes,
|
||||||
sbtClassifiers
|
sbtClassifiers
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@ object ResolutionRun {
|
||||||
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
val printOptionalMessage = verbosityLevel >= 0 && verbosityLevel <= 1
|
||||||
|
|
||||||
val resOrError: Either[ResolutionError, Resolution] = try {
|
val resOrError: Either[ResolutionError, Resolution] = try {
|
||||||
pool = Schedulable.fixedThreadPool(params.parallelDownloads)
|
pool = Schedulable.fixedThreadPool(params.cacheParams.parallel)
|
||||||
resLogger = params.createLogger()
|
resLogger = params.createLogger()
|
||||||
|
|
||||||
val fetchs = Cache.fetchs[Task](params.cache, params.cachePolicies, checksums = params.checksums, logger = Some(resLogger), pool = pool, ttl = params.ttl)
|
val fetchs = Cache.fetchs[Task](params.cacheParams.cacheLocation, params.cacheParams.cachePolicies, checksums = params.cacheParams.checksum, logger = Some(resLogger), pool = pool, ttl = params.cacheParams.ttl)
|
||||||
|
|
||||||
val fetch = ResolutionProcess.fetch(
|
val fetch = ResolutionProcess.fetch(
|
||||||
params.repositories,
|
params.repositories,
|
||||||
|
|
@ -84,7 +84,7 @@ object ResolutionRun {
|
||||||
|
|
||||||
startRes
|
startRes
|
||||||
.process
|
.process
|
||||||
.run(fetch, params.maxIterations)
|
.run(fetch, params.params.maxIterations)
|
||||||
.attempt
|
.attempt
|
||||||
.unsafeRun()(ExecutionContext.fromExecutorService(pool))
|
.unsafeRun()(ExecutionContext.fromExecutorService(pool))
|
||||||
.left
|
.left
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import java.io.File
|
||||||
import coursier.{Artifact, FileError}
|
import coursier.{Artifact, FileError}
|
||||||
import coursier.core._
|
import coursier.core._
|
||||||
import coursier.lmcoursier._
|
import coursier.lmcoursier._
|
||||||
|
import coursier.params.CacheParams
|
||||||
import coursier.sbtcoursier.Keys._
|
import coursier.sbtcoursier.Keys._
|
||||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport.{coursierCache, coursierCreateLogger}
|
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport.{coursierCache, coursierCreateLogger}
|
||||||
import sbt.Def
|
import sbt.Def
|
||||||
|
|
@ -53,17 +54,19 @@ object ArtifactsTasks {
|
||||||
val res = resTask.value
|
val res = resTask.value
|
||||||
|
|
||||||
val params = ArtifactsParams(
|
val params = ArtifactsParams(
|
||||||
classifiers,
|
classifiers = classifiers,
|
||||||
res,
|
res = res,
|
||||||
includeSignatures,
|
includeSignatures = includeSignatures,
|
||||||
parallelDownloads,
|
createLogger = createLogger.create,
|
||||||
createLogger.create,
|
projectName = projectName,
|
||||||
cache,
|
sbtClassifiers = sbtClassifiers,
|
||||||
artifactsChecksums,
|
cacheParams = CacheParams(
|
||||||
ttl,
|
parallel = parallelDownloads,
|
||||||
cachePolicies,
|
cacheLocation = cache,
|
||||||
projectName,
|
checksum = artifactsChecksums,
|
||||||
sbtClassifiers
|
ttl = ttl,
|
||||||
|
cachePolicies = cachePolicies
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
val resOrError = ArtifactsRun.artifacts(
|
val resOrError = ArtifactsRun.artifacts(
|
||||||
|
|
|
||||||
|
|
@ -123,28 +123,30 @@ object ResolutionTasks {
|
||||||
|
|
||||||
val resOrError = ResolutionRun.resolutions(
|
val resOrError = ResolutionRun.resolutions(
|
||||||
ResolutionParams(
|
ResolutionParams(
|
||||||
currentProject.dependencies,
|
dependencies = currentProject.dependencies,
|
||||||
fallbackDependencies,
|
fallbackDependencies = fallbackDependencies,
|
||||||
configGraphs,
|
configGraphs = configGraphs,
|
||||||
autoScalaLib,
|
autoScalaLibOpt = if (autoScalaLib) Some((so, sv)) else None,
|
||||||
mainRepositories,
|
mainRepositories = mainRepositories,
|
||||||
parentProjectCache,
|
parentProjectCache = parentProjectCache,
|
||||||
interProjectDependencies,
|
interProjectDependencies = interProjectDependencies,
|
||||||
internalRepositories,
|
internalRepositories = internalRepositories,
|
||||||
userEnabledProfiles,
|
typelevel = typelevel,
|
||||||
userForceVersions,
|
sbtClassifiers = sbtClassifiers,
|
||||||
typelevel,
|
projectName = projectName,
|
||||||
so,
|
createLogger = createLogger.create,
|
||||||
sv,
|
cacheParams = coursier.params.CacheParams(
|
||||||
sbtClassifiers,
|
cacheLocation = cache,
|
||||||
parallelDownloads,
|
cachePolicies = cachePolicies,
|
||||||
projectName,
|
ttl = ttl,
|
||||||
maxIterations,
|
checksum = checksums,
|
||||||
createLogger.create,
|
parallel = parallelDownloads
|
||||||
cache,
|
),
|
||||||
cachePolicies,
|
params = coursier.params.ResolutionParams(
|
||||||
ttl,
|
maxIterations = maxIterations,
|
||||||
checksums
|
profiles = userEnabledProfiles,
|
||||||
|
forceVersion = userForceVersions
|
||||||
|
)
|
||||||
),
|
),
|
||||||
verbosityLevel,
|
verbosityLevel,
|
||||||
log
|
log
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue