mirror of https://github.com/sbt/sbt.git
Make most things private in lm-coursier
And as much as possible, have sbt-coursier-shared and sbt-lm-coursier use as few as possible things from coursier itself and lm-coursier.
This commit is contained in:
parent
736d5c11c5
commit
d6858b4857
|
|
@ -7,7 +7,6 @@ package coursier.lmcoursier
|
|||
final class CoursierConfiguration private (
|
||||
val log: Option[xsbti.Logger],
|
||||
val resolvers: Vector[sbt.librarymanagement.Resolver],
|
||||
val reorderResolvers: Boolean,
|
||||
val parallelDownloads: Int,
|
||||
val maxIterations: Int,
|
||||
val sbtScalaOrganization: Option[String],
|
||||
|
|
@ -27,20 +26,20 @@ final class CoursierConfiguration private (
|
|||
val logger: Option[coursier.cache.CacheLogger],
|
||||
val cache: Option[java.io.File]) extends Serializable {
|
||||
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, true, 6, 100, None, None, Vector.empty, Vector.empty, Vector.empty, Vector.empty, true, false, Vector.empty, Vector.empty, None, None, Vector.empty, Vector.empty, None, None)
|
||||
private def this() = this(None, sbt.librarymanagement.Resolver.defaults, 6, 100, None, None, Vector.empty, Vector.empty, Vector.empty, Vector.empty, true, false, Vector.empty, Vector.empty, None, None, Vector.empty, Vector.empty, None, None)
|
||||
|
||||
override def equals(o: Any): Boolean = o match {
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.reorderResolvers == x.reorderResolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies) && (this.excludeDependencies == x.excludeDependencies) && (this.fallbackDependencies == x.fallbackDependencies) && (this.autoScalaLibrary == x.autoScalaLibrary) && (this.hasClassifiers == x.hasClassifiers) && (this.classifiers == x.classifiers) && (this.mavenProfiles == x.mavenProfiles) && (this.scalaOrganization == x.scalaOrganization) && (this.scalaVersion == x.scalaVersion) && (this.authenticationByRepositoryId == x.authenticationByRepositoryId) && (this.credentials == x.credentials) && (this.logger == x.logger) && (this.cache == x.cache)
|
||||
case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies) && (this.excludeDependencies == x.excludeDependencies) && (this.fallbackDependencies == x.fallbackDependencies) && (this.autoScalaLibrary == x.autoScalaLibrary) && (this.hasClassifiers == x.hasClassifiers) && (this.classifiers == x.classifiers) && (this.mavenProfiles == x.mavenProfiles) && (this.scalaOrganization == x.scalaOrganization) && (this.scalaVersion == x.scalaVersion) && (this.authenticationByRepositoryId == x.authenticationByRepositoryId) && (this.credentials == x.credentials) && (this.logger == x.logger) && (this.cache == x.cache)
|
||||
case _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##) + fallbackDependencies.##) + autoScalaLibrary.##) + hasClassifiers.##) + classifiers.##) + mavenProfiles.##) + scalaOrganization.##) + scalaVersion.##) + authenticationByRepositoryId.##) + credentials.##) + logger.##) + cache.##)
|
||||
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##) + fallbackDependencies.##) + autoScalaLibrary.##) + hasClassifiers.##) + classifiers.##) + mavenProfiles.##) + scalaOrganization.##) + scalaVersion.##) + authenticationByRepositoryId.##) + credentials.##) + logger.##) + cache.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ", " + autoScalaLibrary + ", " + hasClassifiers + ", " + classifiers + ", " + mavenProfiles + ", " + scalaOrganization + ", " + scalaVersion + ", " + authenticationByRepositoryId + ", " + credentials + ", " + logger + ", " + cache + ")"
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ", " + autoScalaLibrary + ", " + hasClassifiers + ", " + classifiers + ", " + mavenProfiles + ", " + scalaOrganization + ", " + scalaVersion + ", " + authenticationByRepositoryId + ", " + credentials + ", " + logger + ", " + cache + ")"
|
||||
}
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, reorderResolvers: Boolean = reorderResolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[coursier.core.Project] = interProjectDependencies, excludeDependencies: Vector[(String, String)] = excludeDependencies, fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency] = fallbackDependencies, autoScalaLibrary: Boolean = autoScalaLibrary, hasClassifiers: Boolean = hasClassifiers, classifiers: Vector[String] = classifiers, mavenProfiles: Vector[String] = mavenProfiles, scalaOrganization: Option[String] = scalaOrganization, scalaVersion: Option[String] = scalaVersion, authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)] = authenticationByRepositoryId, credentials: Seq[coursier.credentials.Credentials] = credentials, logger: Option[coursier.cache.CacheLogger] = logger, cache: Option[java.io.File] = cache): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, scalaOrganization, scalaVersion, authenticationByRepositoryId, credentials, logger, cache)
|
||||
private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[coursier.core.Project] = interProjectDependencies, excludeDependencies: Vector[(String, String)] = excludeDependencies, fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency] = fallbackDependencies, autoScalaLibrary: Boolean = autoScalaLibrary, hasClassifiers: Boolean = hasClassifiers, classifiers: Vector[String] = classifiers, mavenProfiles: Vector[String] = mavenProfiles, scalaOrganization: Option[String] = scalaOrganization, scalaVersion: Option[String] = scalaVersion, authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)] = authenticationByRepositoryId, credentials: Seq[coursier.credentials.Credentials] = credentials, logger: Option[coursier.cache.CacheLogger] = logger, cache: Option[java.io.File] = cache): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, scalaOrganization, scalaVersion, authenticationByRepositoryId, credentials, logger, cache)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -51,9 +50,6 @@ final class CoursierConfiguration private (
|
|||
def withResolvers(resolvers: Vector[sbt.librarymanagement.Resolver]): CoursierConfiguration = {
|
||||
copy(resolvers = resolvers)
|
||||
}
|
||||
def withReorderResolvers(reorderResolvers: Boolean): CoursierConfiguration = {
|
||||
copy(reorderResolvers = reorderResolvers)
|
||||
}
|
||||
def withParallelDownloads(parallelDownloads: Int): CoursierConfiguration = {
|
||||
copy(parallelDownloads = parallelDownloads)
|
||||
}
|
||||
|
|
@ -130,6 +126,6 @@ final class CoursierConfiguration private (
|
|||
object CoursierConfiguration {
|
||||
|
||||
def apply(): CoursierConfiguration = new CoursierConfiguration()
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency], autoScalaLibrary: Boolean, hasClassifiers: Boolean, classifiers: Vector[String], mavenProfiles: Vector[String], scalaOrganization: Option[String], scalaVersion: Option[String], authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)], credentials: Seq[coursier.credentials.Credentials], logger: Option[coursier.cache.CacheLogger], cache: Option[java.io.File]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, scalaOrganization, scalaVersion, authenticationByRepositoryId, credentials, logger, cache)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], reorderResolvers: Boolean, parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency], autoScalaLibrary: Boolean, hasClassifiers: Boolean, classifiers: Vector[String], mavenProfiles: Vector[String], scalaOrganization: String, scalaVersion: String, authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)], credentials: Seq[coursier.credentials.Credentials], logger: coursier.cache.CacheLogger, cache: java.io.File): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, Option(scalaOrganization), Option(scalaVersion), authenticationByRepositoryId, credentials, Option(logger), Option(cache))
|
||||
def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency], autoScalaLibrary: Boolean, hasClassifiers: Boolean, classifiers: Vector[String], mavenProfiles: Vector[String], scalaOrganization: Option[String], scalaVersion: Option[String], authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)], credentials: Seq[coursier.credentials.Credentials], logger: Option[coursier.cache.CacheLogger], cache: Option[java.io.File]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, scalaOrganization, scalaVersion, authenticationByRepositoryId, credentials, logger, cache)
|
||||
def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[coursier.core.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency], autoScalaLibrary: Boolean, hasClassifiers: Boolean, classifiers: Vector[String], mavenProfiles: Vector[String], scalaOrganization: String, scalaVersion: String, authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)], credentials: Seq[coursier.credentials.Credentials], logger: coursier.cache.CacheLogger, cache: java.io.File): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, Option(scalaOrganization), Option(scalaVersion), authenticationByRepositoryId, credentials, Option(logger), Option(cache))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,6 @@
|
|||
"default": "sbt.librarymanagement.Resolver.defaults",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "reorderResolvers",
|
||||
"type": "Boolean",
|
||||
"default": "true",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "parallelDownloads",
|
||||
"type": "Int",
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@ import java.io.File
|
|||
|
||||
import _root_.coursier.{Artifact, Organization, Resolution, organizationString}
|
||||
import _root_.coursier.core.{Classifier, Configuration, ModuleName}
|
||||
import coursier.cache.{CacheDefaults, FileCache}
|
||||
import coursier.cache.CacheDefaults
|
||||
import coursier.internal.Typelevel
|
||||
import coursier.lmcoursier.internal.{ArtifactsParams, ArtifactsRun, CoursierModuleDescriptor, InterProjectRepository, ResolutionParams, ResolutionRun, SbtBootJars, UpdateParams, UpdateRun}
|
||||
import sbt.internal.librarymanagement.IvySbt
|
||||
import sbt.librarymanagement._
|
||||
import sbt.util.Logger
|
||||
|
|
@ -18,12 +19,6 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
* sbt-coursier, that was moved to this module.
|
||||
*/
|
||||
|
||||
lazy val resolvers =
|
||||
if (conf.reorderResolvers)
|
||||
ResolutionParams.reorderResolvers(conf.resolvers)
|
||||
else
|
||||
conf.resolvers
|
||||
|
||||
private lazy val excludeDependencies = conf
|
||||
.excludeDependencies
|
||||
.map {
|
||||
|
|
@ -32,7 +27,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
}
|
||||
.toSet
|
||||
|
||||
def moduleDescriptor(moduleSetting: ModuleDescriptorConfiguration): CoursierModuleDescriptor =
|
||||
def moduleDescriptor(moduleSetting: ModuleDescriptorConfiguration): ModuleDescriptor =
|
||||
CoursierModuleDescriptor(moduleSetting, conf)
|
||||
|
||||
def update(
|
||||
|
|
@ -88,7 +83,8 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
|
||||
val authenticationByRepositoryId = conf.authenticationByRepositoryId.toMap
|
||||
|
||||
val mainRepositories = resolvers
|
||||
val mainRepositories = conf
|
||||
.resolvers
|
||||
.flatMap { resolver =>
|
||||
FromSbt.repository(
|
||||
resolver,
|
||||
|
|
@ -149,7 +145,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
.withTypelevel(typelevel)
|
||||
)
|
||||
|
||||
def artifactsParams(resolutions: Map[Set[Configuration], Resolution]) =
|
||||
def artifactsParams(resolutions: Map[Set[Configuration], Resolution]): ArtifactsParams =
|
||||
ArtifactsParams(
|
||||
classifiers = classifiers,
|
||||
resolutions = resolutions.values.toSeq,
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
package coursier.lmcoursier
|
||||
|
||||
import sbt.librarymanagement.ModuleSettings
|
||||
|
||||
case class CoursierModuleSettings() extends ModuleSettings
|
||||
|
|
@ -15,14 +15,15 @@ import scala.collection.JavaConverters._
|
|||
|
||||
object FromSbt {
|
||||
|
||||
def sbtModuleIdName(
|
||||
private def sbtModuleIdName(
|
||||
moduleId: ModuleID,
|
||||
scalaVersion: => String,
|
||||
scalaBinaryVersion: => String,
|
||||
optionalCrossVer: Boolean = false
|
||||
): String = {
|
||||
val name0 = moduleId.name
|
||||
val updatedName = sbtCrossVersionName(name0, moduleId.crossVersion, scalaVersion, scalaBinaryVersion)
|
||||
val updatedName = CrossVersion(moduleId.crossVersion, scalaVersion, scalaBinaryVersion)
|
||||
.fold(name0)(_(name0))
|
||||
if (!optionalCrossVer || updatedName.length <= name0.length)
|
||||
updatedName
|
||||
else {
|
||||
|
|
@ -34,37 +35,35 @@ object FromSbt {
|
|||
}
|
||||
}
|
||||
|
||||
def sbtCrossVersionName(
|
||||
name: String,
|
||||
crossVersion: CrossVersion,
|
||||
scalaVersion: => String,
|
||||
scalaBinaryVersion: => String
|
||||
): String =
|
||||
CrossVersion(crossVersion, scalaVersion, scalaBinaryVersion)
|
||||
.fold(name)(_(name))
|
||||
|
||||
def attributes(attr: Map[String, String]): Map[String, String] =
|
||||
private def attributes(attr: Map[String, String]): Map[String, String] =
|
||||
attr.map { case (k, v) =>
|
||||
k.stripPrefix("e:") -> v
|
||||
}.filter { case (k, _) =>
|
||||
!k.startsWith(SbtPomExtraProperties.POM_INFO_KEY_PREFIX)
|
||||
}
|
||||
|
||||
def moduleVersion(
|
||||
private def moduleVersion(
|
||||
module: ModuleID,
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String,
|
||||
optionalCrossVer: Boolean = false
|
||||
optionalCrossVer: Boolean
|
||||
): (Module, String) = {
|
||||
|
||||
val fullName = sbtModuleIdName(module, scalaVersion, scalaBinaryVersion, optionalCrossVer)
|
||||
|
||||
val module0 = Module(Organization(module.organization), ModuleName(fullName), FromSbt.attributes(module.extraDependencyAttributes))
|
||||
val module0 = Module(Organization(module.organization), ModuleName(fullName), attributes(module.extraDependencyAttributes))
|
||||
val version = module.revision
|
||||
|
||||
(module0, version)
|
||||
}
|
||||
|
||||
def moduleVersion(
|
||||
module: ModuleID,
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String
|
||||
): (Module, String) =
|
||||
moduleVersion(module, scalaVersion, scalaBinaryVersion, optionalCrossVer = false)
|
||||
|
||||
def dependencies(
|
||||
module: ModuleID,
|
||||
scalaVersion: String,
|
||||
|
|
@ -120,34 +119,6 @@ object FromSbt {
|
|||
FallbackDependency(module0, version, url, module.isChanging)
|
||||
}
|
||||
|
||||
def sbtClassifiersProject(
|
||||
cm: GetClassifiersModule,
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String
|
||||
) = {
|
||||
|
||||
val p = FromSbt.project(
|
||||
cm.id,
|
||||
cm.dependencies,
|
||||
cm.configurations.map(cfg => Configuration(cfg.name) -> cfg.extendsConfigs.map(c => Configuration(c.name))).toMap,
|
||||
scalaVersion,
|
||||
scalaBinaryVersion
|
||||
)
|
||||
|
||||
// for w/e reasons, the dependencies sometimes don't land in the right config above
|
||||
// this is a loose attempt at fixing that
|
||||
cm.configurations match {
|
||||
case Seq(cfg) =>
|
||||
p.copy(
|
||||
dependencies = p.dependencies.map {
|
||||
case (_, d) => (Configuration(cfg.name), d)
|
||||
}
|
||||
)
|
||||
case _ =>
|
||||
p
|
||||
}
|
||||
}
|
||||
|
||||
def project(
|
||||
projectID: ModuleID,
|
||||
allDependencies: Seq[ModuleID],
|
||||
|
|
@ -162,7 +133,7 @@ object FromSbt {
|
|||
Module(
|
||||
Organization(projectID.organization),
|
||||
ModuleName(sbtModuleIdName(projectID, scalaVersion, scalaBinaryVersion)),
|
||||
FromSbt.attributes(projectID.extraDependencyAttributes)
|
||||
attributes(projectID.extraDependencyAttributes)
|
||||
),
|
||||
projectID.revision,
|
||||
deps,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package coursier.lmcoursier
|
||||
|
||||
import coursier.cache.CacheUrl
|
||||
import coursier.core._
|
||||
import coursier.ivy.IvyRepository
|
||||
import coursier.maven.MavenRepository
|
||||
import sbt.librarymanagement.{InclExclRule, ModuleID}
|
||||
import coursier.core.{Configuration, ModuleName, Organization}
|
||||
import sbt.librarymanagement.{CrossVersion, InclExclRule}
|
||||
import sbt.util.Logger
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.util.Try
|
||||
|
||||
object Inputs {
|
||||
|
||||
|
|
@ -22,7 +18,7 @@ object Inputs {
|
|||
shadedConfig: Option[(String, Configuration)] = None
|
||||
): Map[Configuration, Set[Configuration]] = {
|
||||
|
||||
val configs0 = Inputs.configExtends(configurations)
|
||||
val configs0 = configExtends(configurations)
|
||||
|
||||
def allExtends(c: Configuration) = {
|
||||
// possibly bad complexity
|
||||
|
|
@ -43,11 +39,11 @@ object Inputs {
|
|||
}
|
||||
|
||||
map ++ shadedConfig.toSeq.flatMap {
|
||||
case (baseConfig, shadedConfig) =>
|
||||
case (baseConfig, shadedConfig0) =>
|
||||
val baseConfig0 = Configuration(baseConfig)
|
||||
Seq(
|
||||
baseConfig0 -> (map.getOrElse(baseConfig0, Set(baseConfig0)) + shadedConfig),
|
||||
shadedConfig -> map.getOrElse(shadedConfig, Set(shadedConfig))
|
||||
baseConfig0 -> (map.getOrElse(baseConfig0, Set(baseConfig0)) + shadedConfig0),
|
||||
shadedConfig0 -> map.getOrElse(shadedConfig0, Set(shadedConfig0))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -107,10 +103,11 @@ object Inputs {
|
|||
log.warn(s"Unsupported exclusion rule $rule")
|
||||
anyNonSupportedExclusionRule = true
|
||||
Nil
|
||||
} else
|
||||
Seq(
|
||||
(Organization(rule.organization), ModuleName(FromSbt.sbtCrossVersionName(rule.name, rule.crossVersion, sv, sbv)))
|
||||
)
|
||||
} else {
|
||||
val name = CrossVersion(rule.crossVersion, sv, sbv)
|
||||
.fold(rule.name)(_(rule.name))
|
||||
Seq((Organization(rule.organization), ModuleName(name)))
|
||||
}
|
||||
}
|
||||
.toSet
|
||||
|
||||
|
|
@ -120,67 +117,4 @@ object Inputs {
|
|||
res
|
||||
}
|
||||
|
||||
def coursierProject(
|
||||
projId: ModuleID,
|
||||
dependencies: Seq[ModuleID],
|
||||
excludeDeps: Seq[InclExclRule],
|
||||
configurations: Seq[sbt.librarymanagement.Configuration],
|
||||
sv: String,
|
||||
sbv: String,
|
||||
log: Logger
|
||||
): Project = {
|
||||
|
||||
val exclusions0 = exclusions(excludeDeps, sv, sbv, log)
|
||||
|
||||
val configMap = configExtends(configurations)
|
||||
|
||||
val proj = FromSbt.project(
|
||||
projId,
|
||||
dependencies,
|
||||
configMap,
|
||||
sv,
|
||||
sbv
|
||||
)
|
||||
|
||||
proj.copy(
|
||||
dependencies = proj.dependencies.map {
|
||||
case (config, dep) =>
|
||||
(config, dep.copy(exclusions = dep.exclusions ++ exclusions0))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def withAuthenticationByHost(repo: Repository, credentials: Map[String, Authentication]): Repository = {
|
||||
|
||||
def httpHost(s: String) =
|
||||
if (s.startsWith("http://") || s.startsWith("https://"))
|
||||
Try(CacheUrl.url(s).getHost).toOption
|
||||
else
|
||||
None
|
||||
|
||||
repo match {
|
||||
case m: MavenRepository =>
|
||||
if (m.authentication.isEmpty)
|
||||
httpHost(m.root).flatMap(credentials.get).fold(m) { auth =>
|
||||
m.copy(authentication = Some(auth))
|
||||
}
|
||||
else
|
||||
m
|
||||
case i: IvyRepository =>
|
||||
if (i.authentication.isEmpty) {
|
||||
val base = i.pattern.chunks.takeWhile {
|
||||
case _: coursier.ivy.Pattern.Chunk.Const => true
|
||||
case _ => false
|
||||
}.map(_.string).mkString
|
||||
|
||||
httpHost(base).flatMap(credentials.get).fold(i) { auth =>
|
||||
i.copy(authentication = Some(auth))
|
||||
}
|
||||
} else
|
||||
i
|
||||
case _ =>
|
||||
repo
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
package coursier.lmcoursier
|
||||
|
||||
import sbt.librarymanagement.{ MavenRepository, Resolver, URLRepository }
|
||||
|
||||
object Resolvers {
|
||||
|
||||
private val slowReposBase = Seq(
|
||||
"https://repo.typesafe.com/",
|
||||
"https://repo.scala-sbt.org/",
|
||||
"http://repo.typesafe.com/",
|
||||
"http://repo.scala-sbt.org/"
|
||||
)
|
||||
|
||||
private val fastReposBase = Seq(
|
||||
"http://repo1.maven.org/",
|
||||
"https://repo1.maven.org/"
|
||||
)
|
||||
|
||||
private def url(res: Resolver): Option[String] =
|
||||
res match {
|
||||
case m: MavenRepository =>
|
||||
Some(m.root)
|
||||
case u: URLRepository =>
|
||||
u.patterns.artifactPatterns.headOption
|
||||
.orElse(u.patterns.ivyPatterns.headOption)
|
||||
case _ =>
|
||||
None
|
||||
}
|
||||
|
||||
private def filterResolvers(bases: Seq[String],
|
||||
resolvers: Seq[(Resolver, Option[String])]): Seq[Resolver] =
|
||||
resolvers
|
||||
.filter(tuple => tuple._2.exists(url => bases.exists(base => url.startsWith(base))))
|
||||
.map(_._1)
|
||||
|
||||
def reorder(resolvers: Seq[Resolver]): Seq[Resolver] = {
|
||||
|
||||
val byUrl = resolvers.map(r => (r, url(r)))
|
||||
|
||||
val fast = filterResolvers(fastReposBase, byUrl)
|
||||
val slow = filterResolvers(slowReposBase, byUrl)
|
||||
val rest = resolvers.diff(fast).diff(slow)
|
||||
|
||||
val reordered = fast ++ rest ++ slow
|
||||
assert(reordered.size == resolvers.size,
|
||||
"Reordered resolvers should be the same size as the unordered ones.")
|
||||
|
||||
reordered
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import coursier.cache.{CacheLogger, FileCache}
|
||||
import coursier.core.{Classifier, Resolution}
|
||||
import coursier.util.Task
|
||||
|
||||
final case class ArtifactsParams(
|
||||
private[coursier] final case class ArtifactsParams(
|
||||
classifiers: Option[Seq[Classifier]],
|
||||
resolutions: Seq[Resolution],
|
||||
includeSignatures: Boolean,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import java.io.File
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ import coursier.core.Type
|
|||
import coursier.util.Sync
|
||||
import sbt.util.Logger
|
||||
|
||||
object ArtifactsRun {
|
||||
private[coursier] object ArtifactsRun {
|
||||
|
||||
def artifacts(
|
||||
params: ArtifactsParams,
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import coursier.lmcoursier.CoursierConfiguration
|
||||
import sbt.librarymanagement._
|
||||
|
||||
final case class CoursierModuleDescriptor(
|
||||
private[lmcoursier] final case class CoursierModuleDescriptor(
|
||||
descriptor: ModuleDescriptorConfiguration,
|
||||
conf: CoursierConfiguration
|
||||
) extends ModuleDescriptor {
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package coursier.lmcoursier.internal
|
||||
|
||||
import sbt.librarymanagement.ModuleSettings
|
||||
|
||||
private[lmcoursier] case class CoursierModuleSettings() extends ModuleSettings
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import coursier.core._
|
||||
import coursier.util.{EitherT, Monad}
|
||||
|
||||
final case class InterProjectRepository(projects: Seq[Project]) extends Repository {
|
||||
private[coursier] final case class InterProjectRepository(projects: Seq[Project]) extends Repository {
|
||||
|
||||
private val map = projects
|
||||
.map(proj => proj.moduleVersion -> proj)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
object Lock {
|
||||
private[lmcoursier] object Lock {
|
||||
|
||||
// Wrap blocks downloading stuff (resolution / artifact downloads) in lock.synchronized.
|
||||
// Downloads are already parallel, no need to parallelize further, and this results in
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import java.io.File
|
||||
|
||||
import coursier.cache.{CacheLogger, FileCache}
|
||||
import coursier.ProjectCache
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier.FallbackDependency
|
||||
import coursier.util.{InMemoryRepository, Task}
|
||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||
|
||||
final case class ResolutionParams(
|
||||
private[coursier] final case class ResolutionParams(
|
||||
dependencies: Seq[(Configuration, Dependency)],
|
||||
fallbackDependencies: Seq[FallbackDependency],
|
||||
configGraphs: Seq[Set[Configuration]],
|
||||
|
|
@ -67,7 +67,7 @@ final case class ResolutionParams(
|
|||
|
||||
}
|
||||
|
||||
object ResolutionParams {
|
||||
private[coursier] object ResolutionParams {
|
||||
|
||||
private lazy val m = {
|
||||
val cls = classOf[FileCache[Task]]
|
||||
|
|
@ -99,40 +99,4 @@ object ResolutionParams {
|
|||
) ++ sys.props
|
||||
}
|
||||
|
||||
private val slowReposBase = Seq(
|
||||
"https://repo.typesafe.com/",
|
||||
"https://repo.scala-sbt.org/",
|
||||
"http://repo.typesafe.com/",
|
||||
"http://repo.scala-sbt.org/"
|
||||
)
|
||||
|
||||
private val fastReposBase = Seq(
|
||||
"http://repo1.maven.org/",
|
||||
"https://repo1.maven.org/"
|
||||
)
|
||||
|
||||
private def url(res: Resolver): Option[String] =
|
||||
res match {
|
||||
case m: sbt.librarymanagement.MavenRepository =>
|
||||
Some(m.root)
|
||||
case u: URLRepository =>
|
||||
u.patterns.artifactPatterns.headOption
|
||||
.orElse(u.patterns.ivyPatterns.headOption)
|
||||
case _ =>
|
||||
None
|
||||
}
|
||||
|
||||
private def fastRepo(res: Resolver): Boolean =
|
||||
url(res).exists(u => fastReposBase.exists(u.startsWith))
|
||||
|
||||
private def slowRepo(res: Resolver): Boolean =
|
||||
url(res).exists(u => slowReposBase.exists(u.startsWith))
|
||||
|
||||
def reorderResolvers(resolvers: Seq[Resolver]): Seq[Resolver] =
|
||||
if (resolvers.exists(fastRepo) && resolvers.exists(slowRepo)) {
|
||||
val (slow, other) = resolvers.partition(slowRepo)
|
||||
other ++ slow
|
||||
} else
|
||||
resolvers
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import coursier.{Resolution, Resolve}
|
||||
import coursier.cache.loggers.{FallbackRefreshDisplay, ProgressBarRefreshDisplay, RefreshLogger}
|
||||
|
|
@ -8,9 +8,9 @@ import coursier.maven.MavenRepository
|
|||
import coursier.util.Sync
|
||||
import sbt.util.Logger
|
||||
|
||||
object ResolutionRun {
|
||||
private[coursier] object ResolutionRun {
|
||||
|
||||
def resolution(
|
||||
private def resolution(
|
||||
params: ResolutionParams,
|
||||
verbosityLevel: Int,
|
||||
log: Logger,
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import java.io.File
|
||||
|
||||
import coursier.core.{Module, ModuleName, Organization}
|
||||
|
||||
object SbtBootJars {
|
||||
private[coursier] object SbtBootJars {
|
||||
def apply(
|
||||
scalaOrg: Organization,
|
||||
scalaVersion: String,
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
import coursier.core._
|
||||
import sbt.librarymanagement.UpdateReport
|
||||
|
||||
class SbtCoursierCache {
|
||||
private[coursier] class SbtCoursierCache {
|
||||
|
||||
import SbtCoursierCache._
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class SbtCoursierCache {
|
|||
|
||||
}
|
||||
|
||||
object SbtCoursierCache {
|
||||
private[coursier] object SbtCoursierCache {
|
||||
|
||||
final case class ResolutionKey(
|
||||
dependencies: Seq[(Configuration, Dependency)],
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
|
|
@ -11,7 +11,7 @@ import coursier.maven.MavenAttributes
|
|||
import sbt.librarymanagement.{Artifact => _, Configuration => _, _}
|
||||
import sbt.util.Logger
|
||||
|
||||
object ToSbt {
|
||||
private[internal] object SbtUpdateReport {
|
||||
|
||||
private def caching[K, V](f: K => V): K => V = {
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ object ToSbt {
|
|||
}
|
||||
}
|
||||
|
||||
val moduleId = caching[(Dependency, String, Map[String, String]), ModuleID] {
|
||||
private val moduleId = caching[(Dependency, String, Map[String, String]), ModuleID] {
|
||||
case (dependency, version, extraProperties) =>
|
||||
sbt.librarymanagement.ModuleID(
|
||||
dependency.module.organization.value,
|
||||
|
|
@ -52,7 +52,7 @@ object ToSbt {
|
|||
)
|
||||
}
|
||||
|
||||
val artifact = caching[(Module, Map[String, String], Attributes, Artifact), sbt.librarymanagement.Artifact] {
|
||||
private val artifact = caching[(Module, Map[String, String], Attributes, Artifact), sbt.librarymanagement.Artifact] {
|
||||
case (module, extraProperties, attr, artifact) =>
|
||||
sbt.librarymanagement.Artifact(module.name.value)
|
||||
// FIXME Get these two from publications
|
||||
|
|
@ -69,16 +69,16 @@ object ToSbt {
|
|||
.withExtraAttributes(module.attributes ++ extraProperties)
|
||||
}
|
||||
|
||||
val moduleReport = caching[(Dependency, Seq[(Dependency, Project)], Project, Seq[(Attributes, Artifact, Option[File])]), ModuleReport] {
|
||||
private val moduleReport = caching[(Dependency, Seq[(Dependency, Project)], Project, Seq[(Attributes, Artifact, Option[File])]), ModuleReport] {
|
||||
case (dependency, dependees, project, artifacts) =>
|
||||
|
||||
val sbtArtifacts = artifacts.collect {
|
||||
case (attr, artifact, Some(file)) =>
|
||||
(ToSbt.artifact(dependency.module, project.properties.toMap, attr, artifact), file)
|
||||
case (attr, artifact0, Some(file)) =>
|
||||
(artifact(dependency.module, project.properties.toMap, attr, artifact0), file)
|
||||
}
|
||||
val sbtMissingArtifacts = artifacts.collect {
|
||||
case (attr, artifact, None) =>
|
||||
ToSbt.artifact(dependency.module, project.properties.toMap, attr, artifact)
|
||||
case (attr, artifact0, None) =>
|
||||
artifact(dependency.module, project.properties.toMap, attr, artifact0)
|
||||
}
|
||||
|
||||
val publicationDate = project.info.publication.map { dt =>
|
||||
|
|
@ -88,7 +88,7 @@ object ToSbt {
|
|||
val callers = dependees.map {
|
||||
case (dependee, dependeeProj) =>
|
||||
Caller(
|
||||
ToSbt.moduleId(dependee, dependeeProj.version, dependeeProj.properties.toMap),
|
||||
moduleId(dependee, dependeeProj.version, dependeeProj.properties.toMap),
|
||||
dependeeProj.configurations.keys.toVector.map(c => ConfigRef(c.value)),
|
||||
dependee.module.attributes ++ dependeeProj.properties,
|
||||
// FIXME Set better values here
|
||||
|
|
@ -100,7 +100,7 @@ object ToSbt {
|
|||
}
|
||||
|
||||
ModuleReport(
|
||||
ToSbt.moduleId(dependency, project.version, project.properties.toMap),
|
||||
moduleId(dependency, project.version, project.properties.toMap),
|
||||
sbtArtifacts.toVector,
|
||||
sbtMissingArtifacts.toVector
|
||||
)
|
||||
|
|
@ -121,7 +121,7 @@ object ToSbt {
|
|||
.withCallers(callers.toVector)
|
||||
}
|
||||
|
||||
def moduleReports(
|
||||
private def moduleReports(
|
||||
res: Resolution,
|
||||
classifiersOpt: Option[Seq[Classifier]],
|
||||
artifactFileOpt: (Module, String, Attributes, Artifact) => Option[File],
|
||||
|
|
@ -196,7 +196,7 @@ object ToSbt {
|
|||
(dependee, dependeeProj)
|
||||
}
|
||||
|
||||
ToSbt.moduleReport(
|
||||
moduleReport(
|
||||
dep,
|
||||
dependees,
|
||||
proj,
|
||||
|
|
@ -205,7 +205,7 @@ object ToSbt {
|
|||
}
|
||||
}
|
||||
|
||||
def updateReport(
|
||||
def apply(
|
||||
configDependencies: Map[Configuration, Seq[Dependency]],
|
||||
resolutions: Map[Configuration, Resolution],
|
||||
configs: Map[Configuration, Set[Configuration]],
|
||||
|
|
@ -225,7 +225,7 @@ object ToSbt {
|
|||
.distinct
|
||||
val subRes = resolutions(config).subset(configDeps)
|
||||
|
||||
val reports = ToSbt.moduleReports(
|
||||
val reports = moduleReports(
|
||||
subRes,
|
||||
classifiersOpt,
|
||||
artifactFileOpt,
|
||||
|
|
@ -240,7 +240,7 @@ object ToSbt {
|
|||
// appears first in the update report, see https://github.com/coursier/coursier/issues/650
|
||||
val dep = subRes.rootDependencies.head
|
||||
val (_, proj) = subRes.projectCache(dep.moduleVersion)
|
||||
val mod = ToSbt.moduleId(dep, proj.version, proj.properties.toMap)
|
||||
val mod = moduleId(dep, proj.version, proj.properties.toMap)
|
||||
val (main, other) = reports.partition { r =>
|
||||
r.module.organization == mod.organization &&
|
||||
r.module.name == mod.name &&
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import java.io.File
|
||||
|
||||
import coursier.core._
|
||||
|
||||
final case class UpdateParams(
|
||||
private[coursier] final case class UpdateParams(
|
||||
shadedConfigOpt: Option[(String, Configuration)],
|
||||
artifacts: Map[Artifact, File],
|
||||
classifiers: Option[Seq[Classifier]],
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package coursier.lmcoursier
|
||||
package coursier.lmcoursier.internal
|
||||
|
||||
import coursier.core.Resolution.ModuleVersion
|
||||
import coursier.core._
|
||||
|
|
@ -6,7 +6,7 @@ import coursier.util.Print
|
|||
import sbt.librarymanagement.UpdateReport
|
||||
import sbt.util.Logger
|
||||
|
||||
object UpdateRun {
|
||||
private[coursier] object UpdateRun {
|
||||
|
||||
// Move back to coursier.util (in core module) after 1.0?
|
||||
private def allDependenciesByConfig(
|
||||
|
|
@ -54,7 +54,7 @@ object UpdateRun {
|
|||
params: UpdateParams,
|
||||
verbosityLevel: Int,
|
||||
log: Logger
|
||||
): UpdateReport = {
|
||||
): UpdateReport = Lock.lock.synchronized {
|
||||
|
||||
val configResolutions = params.res.flatMap {
|
||||
case (configs, r) =>
|
||||
|
|
@ -83,7 +83,7 @@ object UpdateRun {
|
|||
log.info(repr.split('\n').map(" " + _).mkString("\n"))
|
||||
}
|
||||
|
||||
ToSbt.updateReport(
|
||||
SbtUpdateReport(
|
||||
depsByConfig,
|
||||
configResolutions,
|
||||
params.configs,
|
||||
|
|
@ -152,15 +152,4 @@ final class ResolutionSpec extends PropSpec with Matchers {
|
|||
|
||||
resolution should be('right)
|
||||
}
|
||||
|
||||
property("reorder fast and slow resolvers") {
|
||||
val resolvers = Vector(
|
||||
JavaNet2Repository,
|
||||
Resolver.sbtPluginRepo("releases"),
|
||||
DefaultMavenRepository
|
||||
)
|
||||
val engine = new CoursierDependencyResolution(CoursierConfiguration().withResolvers(resolvers))
|
||||
engine.resolvers.last.name should be("sbt-plugin-releases")
|
||||
engine.resolvers should have size resolvers.length
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.core.{Classifier, Configuration, Extension, Publication, Type}
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.librarymanagement.{Artifact => _, Configuration => _, _}
|
||||
import sbt.Def
|
||||
|
|
@ -97,12 +96,8 @@ object ArtifactsTasks {
|
|||
|
||||
def artifactPublication(artifact: sbt.Artifact) = {
|
||||
|
||||
val name = FromSbt.sbtCrossVersionName(
|
||||
artifact.name,
|
||||
projId.crossVersion,
|
||||
sv,
|
||||
sbv
|
||||
)
|
||||
val name = CrossVersion(projId.crossVersion, sv, sbv)
|
||||
.fold(artifact.name)(_(artifact.name))
|
||||
|
||||
Publication(
|
||||
name,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,49 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.core._
|
||||
import coursier.core.{Attributes, Classifier, Configuration, Dependency, Info, Module, ModuleName, Organization, Project, Type}
|
||||
import coursier.credentials.DirectCredentials
|
||||
import coursier.lmcoursier._
|
||||
import coursier.lmcoursier.{FallbackDependency, FromSbt, Inputs}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.{InclExclRule, ModuleID}
|
||||
import sbt.util.Logger
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object InputsTasks {
|
||||
|
||||
private def coursierProject0(
|
||||
projId: ModuleID,
|
||||
dependencies: Seq[ModuleID],
|
||||
excludeDeps: Seq[InclExclRule],
|
||||
configurations: Seq[sbt.librarymanagement.Configuration],
|
||||
sv: String,
|
||||
sbv: String,
|
||||
log: Logger
|
||||
): Project = {
|
||||
|
||||
val exclusions0 = Inputs.exclusions(excludeDeps, sv, sbv, log)
|
||||
|
||||
val configMap = Inputs.configExtends(configurations)
|
||||
|
||||
val proj = FromSbt.project(
|
||||
projId,
|
||||
dependencies,
|
||||
configMap,
|
||||
sv,
|
||||
sbv
|
||||
)
|
||||
|
||||
proj.copy(
|
||||
dependencies = proj.dependencies.map {
|
||||
case (config, dep) =>
|
||||
(config, dep.copy(exclusions = dep.exclusions ++ exclusions0))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def coursierProjectTask: Def.Initialize[sbt.Task[Project]] =
|
||||
Def.taskDyn {
|
||||
|
||||
|
|
@ -21,7 +53,7 @@ object InputsTasks {
|
|||
val allDependenciesTask = allDependencies.in(projectRef).get(state)
|
||||
|
||||
Def.task {
|
||||
Inputs.coursierProject(
|
||||
coursierProject0(
|
||||
projectID.in(projectRef).get(state),
|
||||
allDependenciesTask.value,
|
||||
excludeDependencies.in(projectRef).get(state),
|
||||
|
|
|
|||
|
|
@ -1,14 +1,53 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import coursier.sbtcoursiershared.Structure._
|
||||
import sbt.{Classpaths, Def}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.Resolver
|
||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||
|
||||
object RepositoriesTasks {
|
||||
|
||||
private object Resolvers {
|
||||
|
||||
private val slowReposBase = Seq(
|
||||
"https://repo.typesafe.com/",
|
||||
"https://repo.scala-sbt.org/",
|
||||
"http://repo.typesafe.com/",
|
||||
"http://repo.scala-sbt.org/"
|
||||
)
|
||||
|
||||
private val fastReposBase = Seq(
|
||||
"http://repo1.maven.org/",
|
||||
"https://repo1.maven.org/"
|
||||
)
|
||||
|
||||
private def url(res: Resolver): Option[String] =
|
||||
res match {
|
||||
case m: sbt.librarymanagement.MavenRepository =>
|
||||
Some(m.root)
|
||||
case u: URLRepository =>
|
||||
u.patterns.artifactPatterns.headOption
|
||||
.orElse(u.patterns.ivyPatterns.headOption)
|
||||
case _ =>
|
||||
None
|
||||
}
|
||||
|
||||
private def fastRepo(res: Resolver): Boolean =
|
||||
url(res).exists(u => fastReposBase.exists(u.startsWith))
|
||||
|
||||
private def slowRepo(res: Resolver): Boolean =
|
||||
url(res).exists(u => slowReposBase.exists(u.startsWith))
|
||||
|
||||
def reorderResolvers(resolvers: Seq[Resolver]): Seq[Resolver] =
|
||||
if (resolvers.exists(fastRepo) && resolvers.exists(slowRepo)) {
|
||||
val (slow, other) = resolvers.partition(slowRepo)
|
||||
other ++ slow
|
||||
} else
|
||||
resolvers
|
||||
|
||||
}
|
||||
|
||||
private def resultTask(bootResOpt: Option[Seq[Resolver]], overrideFlag: Boolean): Def.Initialize[sbt.Task[Seq[Resolver]]] =
|
||||
bootResOpt.filter(_ => overrideFlag) match {
|
||||
case Some(r) => Def.task(r)
|
||||
|
|
@ -41,7 +80,7 @@ object RepositoriesTasks {
|
|||
|
||||
val result0 =
|
||||
if (reorderResolvers)
|
||||
ResolutionParams.reorderResolvers(result)
|
||||
Resolvers.reorderResolvers(result)
|
||||
else
|
||||
result
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import coursier.cache.{CacheDefaults, CacheLogger}
|
|||
import coursier.{Credentials => LegacyCredentials}
|
||||
import coursier.core.{Configuration, Project, Publication}
|
||||
import coursier.credentials.Credentials
|
||||
import coursier.lmcoursier.{FallbackDependency, SbtCoursierCache}
|
||||
import coursier.lmcoursier.FallbackDependency
|
||||
import coursier.lmcoursier.internal.SbtCoursierCache
|
||||
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import coursier.Artifact
|
|||
import coursier.cache.FileCache
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.lmcoursier.internal.{ArtifactsParams, ArtifactsRun}
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.InputsTasks.credentialsTask
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport.{coursierCache, coursierLogger}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package coursier.sbtcoursier
|
||||
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.parse.ModuleParser
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
|
|
@ -26,7 +25,7 @@ object DisplayTasks {
|
|||
val sv = scalaVersion.value
|
||||
val sbv = scalaBinaryVersion.value
|
||||
val cm = coursierSbtClassifiersModule.value
|
||||
FromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
SbtCoursierFromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
}
|
||||
else
|
||||
Def.task {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ import coursier.ProjectCache
|
|||
import coursier.cache.FileCache
|
||||
import coursier.core._
|
||||
import coursier.internal.Typelevel
|
||||
import coursier.lmcoursier._
|
||||
import coursier.lmcoursier.{FallbackDependency, FromSbt}
|
||||
import coursier.lmcoursier.internal.{InterProjectRepository, ResolutionParams, ResolutionRun}
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.InputsTasks.credentialsTask
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
|
|
@ -23,7 +24,7 @@ object ResolutionTasks {
|
|||
val sv = scalaVersion.value
|
||||
val sbv = scalaBinaryVersion.value
|
||||
val cm = coursierSbtClassifiersModule.value
|
||||
val proj = FromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
val proj = SbtCoursierFromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
|
||||
val fallbackDeps = FromSbt.fallbackDependencies(
|
||||
cm.dependencies,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package coursier.sbtcoursier
|
||||
|
||||
import coursier.core.Configuration
|
||||
import coursier.lmcoursier.FromSbt
|
||||
import sbt.librarymanagement.GetClassifiersModule
|
||||
|
||||
object SbtCoursierFromSbt {
|
||||
|
||||
def sbtClassifiersProject(
|
||||
cm: GetClassifiersModule,
|
||||
scalaVersion: String,
|
||||
scalaBinaryVersion: String
|
||||
) = {
|
||||
|
||||
val p = FromSbt.project(
|
||||
cm.id,
|
||||
cm.dependencies,
|
||||
cm.configurations.map(cfg => Configuration(cfg.name) -> cfg.extendsConfigs.map(c => Configuration(c.name))).toMap,
|
||||
scalaVersion,
|
||||
scalaBinaryVersion
|
||||
)
|
||||
|
||||
// for w/e reasons, the dependencies sometimes don't land in the right config above
|
||||
// this is a loose attempt at fixing that
|
||||
cm.configurations match {
|
||||
case Seq(cfg) =>
|
||||
p.copy(
|
||||
dependencies = p.dependencies.map {
|
||||
case (_, d) => (Configuration(cfg.name), d)
|
||||
}
|
||||
)
|
||||
case _ =>
|
||||
p
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package coursier.sbtcoursier
|
||||
|
||||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.lmcoursier.internal.{SbtBootJars, SbtCoursierCache, UpdateParams, UpdateRun}
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import sbt.Def
|
||||
|
|
@ -22,7 +22,7 @@ object UpdateTasks {
|
|||
Def.task {
|
||||
val sv = scalaVersion.value
|
||||
val sbv = scalaBinaryVersion.value
|
||||
FromSbt.sbtClassifiersProject(coursierSbtClassifiersModule.value, sv, sbv)
|
||||
SbtCoursierFromSbt.sbtClassifiersProject(coursierSbtClassifiersModule.value, sv, sbv)
|
||||
}
|
||||
else
|
||||
Def.task {
|
||||
|
|
@ -134,10 +134,7 @@ object UpdateTasks {
|
|||
sbtBootJarOverrides
|
||||
)
|
||||
|
||||
val rep =
|
||||
Lock.lock.synchronized {
|
||||
UpdateRun.update(params, verbosityLevel, log)
|
||||
}
|
||||
val rep = UpdateRun.update(params, verbosityLevel, log)
|
||||
SbtCoursierCache.default.putReport(key, rep)
|
||||
rep
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ package coursier
|
|||
object Helper {
|
||||
|
||||
def checkEmpty(): Boolean =
|
||||
coursier.lmcoursier.SbtCoursierCache.default.isEmpty
|
||||
coursier.lmcoursier.internal.SbtCoursierCache.default.isEmpty
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ check := {
|
|||
sbtResolvers.flatMap{ sbtResolver: sbt.librarymanagement.Resolver =>
|
||||
coursier.lmcoursier.FromSbt.repository(
|
||||
resolver = sbtResolver,
|
||||
ivyProperties = coursier.lmcoursier.ResolutionParams.defaultIvyProperties(),
|
||||
ivyProperties = coursier.lmcoursier.internal.ResolutionParams.defaultIvyProperties(),
|
||||
log = s.log,
|
||||
authentication = None,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package coursier.sbtlmcoursier
|
||||
|
||||
import coursier.core.Classifier
|
||||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||
import coursier.sbtcoursiershared.InputsTasks.credentialsTask
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
|
|
@ -67,9 +66,9 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
coursierSbtResolvers
|
||||
else
|
||||
coursierRecursiveResolvers
|
||||
val classifiersTask: sbt.Def.Initialize[sbt.Task[Option[Seq[Classifier]]]] =
|
||||
val classifiersTask: sbt.Def.Initialize[sbt.Task[Option[Seq[String]]]] =
|
||||
if (withClassifiers && !sbtClassifiers)
|
||||
Def.task(Some(sbt.Keys.transitiveClassifiers.value.map(Classifier(_))))
|
||||
Def.task(Some(sbt.Keys.transitiveClassifiers.value))
|
||||
else
|
||||
Def.task(None)
|
||||
Def.task {
|
||||
|
|
@ -118,7 +117,7 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
.withSbtScalaJars(sbtBootJars.toVector)
|
||||
.withSbtScalaVersion(sbtScalaVersion)
|
||||
.withSbtScalaOrganization(sbtScalaOrganization)
|
||||
.withClassifiers(classifiers.toVector.flatten.map(_.value))
|
||||
.withClassifiers(classifiers.toVector.flatten)
|
||||
.withHasClassifiers(classifiers.nonEmpty)
|
||||
.withMavenProfiles(profiles.toVector.sorted)
|
||||
.withScalaOrganization(scalaOrg)
|
||||
|
|
|
|||
Loading…
Reference in New Issue