mirror of https://github.com/sbt/sbt.git
Merge pull request #10 from alexarchambault/develop
Make sbt-lm-coursier pass more scripted tests
This commit is contained in:
commit
05f8f321d9
|
|
@ -18,22 +18,29 @@ final class CoursierConfiguration private (
|
|||
val fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency],
|
||||
val autoScalaLibrary: Boolean,
|
||||
val hasClassifiers: Boolean,
|
||||
val classifiers: Vector[String]) extends Serializable {
|
||||
val classifiers: Vector[String],
|
||||
val mavenProfiles: Vector[String],
|
||||
val scalaOrganization: Option[String],
|
||||
val scalaVersion: Option[String],
|
||||
val authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)],
|
||||
val authenticationByHost: Vector[(String, coursier.core.Authentication)],
|
||||
val createLogger: Option[coursier.lmcoursier.CreateLogger],
|
||||
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)
|
||||
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)
|
||||
|
||||
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)
|
||||
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.authenticationByHost == x.authenticationByHost) && (this.createLogger == x.createLogger) && (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 * (17 + "coursier.lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + reorderResolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##) + fallbackDependencies.##) + autoScalaLibrary.##) + hasClassifiers.##) + classifiers.##)
|
||||
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.##) + authenticationByHost.##) + createLogger.##) + cache.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ", " + autoScalaLibrary + ", " + hasClassifiers + ", " + classifiers + ")"
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ", " + autoScalaLibrary + ", " + hasClassifiers + ", " + classifiers + ", " + mavenProfiles + ", " + scalaOrganization + ", " + scalaVersion + ", " + authenticationByRepositoryId + ", " + authenticationByHost + ", " + createLogger + ", " + 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): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers)
|
||||
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, authenticationByHost: Vector[(String, coursier.core.Authentication)] = authenticationByHost, createLogger: Option[coursier.lmcoursier.CreateLogger] = createLogger, 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, authenticationByHost, createLogger, cache)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -86,10 +93,43 @@ final class CoursierConfiguration private (
|
|||
def withClassifiers(classifiers: Vector[String]): CoursierConfiguration = {
|
||||
copy(classifiers = classifiers)
|
||||
}
|
||||
def withMavenProfiles(mavenProfiles: Vector[String]): CoursierConfiguration = {
|
||||
copy(mavenProfiles = mavenProfiles)
|
||||
}
|
||||
def withScalaOrganization(scalaOrganization: Option[String]): CoursierConfiguration = {
|
||||
copy(scalaOrganization = scalaOrganization)
|
||||
}
|
||||
def withScalaOrganization(scalaOrganization: String): CoursierConfiguration = {
|
||||
copy(scalaOrganization = Option(scalaOrganization))
|
||||
}
|
||||
def withScalaVersion(scalaVersion: Option[String]): CoursierConfiguration = {
|
||||
copy(scalaVersion = scalaVersion)
|
||||
}
|
||||
def withScalaVersion(scalaVersion: String): CoursierConfiguration = {
|
||||
copy(scalaVersion = Option(scalaVersion))
|
||||
}
|
||||
def withAuthenticationByRepositoryId(authenticationByRepositoryId: Vector[(String, coursier.core.Authentication)]): CoursierConfiguration = {
|
||||
copy(authenticationByRepositoryId = authenticationByRepositoryId)
|
||||
}
|
||||
def withAuthenticationByHost(authenticationByHost: Vector[(String, coursier.core.Authentication)]): CoursierConfiguration = {
|
||||
copy(authenticationByHost = authenticationByHost)
|
||||
}
|
||||
def withCreateLogger(createLogger: Option[coursier.lmcoursier.CreateLogger]): CoursierConfiguration = {
|
||||
copy(createLogger = createLogger)
|
||||
}
|
||||
def withCreateLogger(createLogger: coursier.lmcoursier.CreateLogger): CoursierConfiguration = {
|
||||
copy(createLogger = Option(createLogger))
|
||||
}
|
||||
def withCache(cache: Option[java.io.File]): CoursierConfiguration = {
|
||||
copy(cache = cache)
|
||||
}
|
||||
def withCache(cache: java.io.File): CoursierConfiguration = {
|
||||
copy(cache = Option(cache))
|
||||
}
|
||||
}
|
||||
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]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers)
|
||||
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]): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers)
|
||||
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)], authenticationByHost: Vector[(String, coursier.core.Authentication)], createLogger: Option[coursier.lmcoursier.CreateLogger], 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, authenticationByHost, createLogger, 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)], authenticationByHost: Vector[(String, coursier.core.Authentication)], createLogger: coursier.lmcoursier.CreateLogger, 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, authenticationByHost, Option(createLogger), Option(cache))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,48 @@
|
|||
"type": "String*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "mavenProfiles",
|
||||
"type": "String*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "scalaOrganization",
|
||||
"type": "String?",
|
||||
"default": "None",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "scalaVersion",
|
||||
"type": "String?",
|
||||
"default": "None",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "authenticationByRepositoryId",
|
||||
"type": "(String, coursier.core.Authentication)*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "authenticationByHost",
|
||||
"type": "(String, coursier.core.Authentication)*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "createLogger",
|
||||
"type": "coursier.lmcoursier.CreateLogger?",
|
||||
"default": "None",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "cache",
|
||||
"type": "java.io.File?",
|
||||
"default": "None",
|
||||
"since": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import java.io.{File, OutputStreamWriter}
|
|||
|
||||
import _root_.coursier.{Artifact, Cache, CachePolicy, FileError, Organization, Resolution, TermDisplay, organizationString}
|
||||
import _root_.coursier.core.{Classifier, Configuration, ModuleName}
|
||||
import _root_.coursier.extra.Typelevel
|
||||
import _root_.coursier.ivy.IvyRepository
|
||||
import _root_.coursier.lmcoursier.Inputs.withAuthenticationByHost
|
||||
import sbt.internal.librarymanagement.IvySbt
|
||||
import sbt.librarymanagement._
|
||||
import sbt.util.Logger
|
||||
|
|
@ -52,8 +54,11 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
sys.error(s"unrecognized ModuleDescriptor type: $module")
|
||||
}
|
||||
|
||||
val so = module0.scalaModuleInfo.fold(org"org.scala-lang")(m => Organization(m.scalaOrganization))
|
||||
val sv = module0.scalaModuleInfo.map(_.scalaFullVersion)
|
||||
val so = conf.scalaOrganization.map(Organization(_))
|
||||
.orElse(module0.scalaModuleInfo.map(m => Organization(m.scalaOrganization)))
|
||||
.getOrElse(org"org.scala-lang")
|
||||
val sv = conf.scalaVersion
|
||||
.orElse(module0.scalaModuleInfo.map(_.scalaFullVersion))
|
||||
// FIXME Manage to do stuff below without a scala version?
|
||||
.getOrElse(scala.util.Properties.versionNumberString)
|
||||
|
||||
|
|
@ -64,10 +69,10 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
val verbosityLevel = 0
|
||||
|
||||
val ttl = Cache.defaultTtl
|
||||
val createLogger = { () =>
|
||||
val createLogger = conf.createLogger.map(_.create).getOrElse { () =>
|
||||
new TermDisplay(new OutputStreamWriter(System.err), fallbackMode = true)
|
||||
}
|
||||
val cache = Cache.default
|
||||
val cache = conf.cache.getOrElse(Cache.default)
|
||||
val cachePolicies = CachePolicy.default
|
||||
val checksums = Cache.defaultChecksums
|
||||
val projectName = "" // used for logging only…
|
||||
|
|
@ -80,15 +85,18 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
else
|
||||
None
|
||||
|
||||
val authenticationByRepositoryId = conf.authenticationByRepositoryId.toMap
|
||||
|
||||
val mainRepositories = resolvers
|
||||
.flatMap { resolver =>
|
||||
FromSbt.repository(
|
||||
resolver,
|
||||
ivyProperties,
|
||||
log,
|
||||
None // FIXME What about authentication?
|
||||
authenticationByRepositoryId.get(resolver.name)
|
||||
)
|
||||
}
|
||||
.map(withAuthenticationByHost(_, conf.authenticationByHost.toMap))
|
||||
|
||||
val globalPluginsRepos =
|
||||
for (p <- ResolutionParams.globalPluginPatterns(sbtBinaryVersion))
|
||||
|
|
@ -122,6 +130,8 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
Inputs.configExtends(module0.configurations)
|
||||
)
|
||||
|
||||
val typelevel = so == Typelevel.typelevelOrg
|
||||
|
||||
val resolutionParams = ResolutionParams(
|
||||
dependencies = dependencies,
|
||||
fallbackDependencies = conf.fallbackDependencies,
|
||||
|
|
@ -131,9 +141,9 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
parentProjectCache = Map.empty,
|
||||
interProjectDependencies = conf.interProjectDependencies,
|
||||
internalRepositories = internalRepositories,
|
||||
userEnabledProfiles = Set.empty,
|
||||
userEnabledProfiles = conf.mavenProfiles.toSet,
|
||||
userForceVersions = Map.empty,
|
||||
typelevel = false,
|
||||
typelevel = typelevel,
|
||||
so = so,
|
||||
sv = sv,
|
||||
sbtClassifiers = false,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
package coursier.lmcoursier
|
||||
|
||||
final case class CreateLogger(create: () => coursier.Cache.Logger)
|
||||
|
|
@ -1,10 +1,14 @@
|
|||
package coursier.lmcoursier
|
||||
|
||||
import coursier.core.{Configuration, ModuleName, Organization, Project}
|
||||
import coursier.Cache
|
||||
import coursier.core._
|
||||
import coursier.ivy.IvyRepository
|
||||
import coursier.maven.MavenRepository
|
||||
import sbt.librarymanagement.{InclExclRule, ModuleID}
|
||||
import sbt.util.Logger
|
||||
|
||||
import scala.collection.mutable
|
||||
import scala.util.Try
|
||||
|
||||
object Inputs {
|
||||
|
||||
|
|
@ -146,4 +150,37 @@ object Inputs {
|
|||
)
|
||||
}
|
||||
|
||||
def withAuthenticationByHost(repo: Repository, credentials: Map[String, Authentication]): Repository = {
|
||||
|
||||
def httpHost(s: String) =
|
||||
if (s.startsWith("http://") || s.startsWith("https://"))
|
||||
Try(Cache.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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,32 @@ object InputsTasks {
|
|||
}
|
||||
}
|
||||
|
||||
val authenticationByHostTask = Def.taskDyn {
|
||||
|
||||
val useSbtCredentials = coursierUseSbtCredentials.value
|
||||
|
||||
if (useSbtCredentials)
|
||||
Def.task {
|
||||
val log = streams.value.log
|
||||
|
||||
sbt.Keys.credentials.value
|
||||
.flatMap {
|
||||
case dc: sbt.DirectCredentials => List(dc)
|
||||
case fc: sbt.FileCredentials =>
|
||||
sbt.Credentials.loadCredentials(fc.path) match {
|
||||
case Left(err) =>
|
||||
log.warn(s"$err, ignoring it")
|
||||
Nil
|
||||
case Right(dc) => List(dc)
|
||||
}
|
||||
}
|
||||
.map { c =>
|
||||
c.host -> Authentication(c.userName, c.passwd)
|
||||
}
|
||||
.toMap
|
||||
}
|
||||
else
|
||||
Def.task(Map.empty[String, Authentication])
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import java.io.{File, OutputStreamWriter}
|
||||
|
||||
import coursier.{Cache, Credentials, TermDisplay}
|
||||
import coursier.core.{Configuration, Project, Publication}
|
||||
import coursier.lmcoursier.{FallbackDependency, SbtCoursierCache}
|
||||
import coursier.lmcoursier.{CreateLogger, FallbackDependency, SbtCoursierCache}
|
||||
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.{Resolver, URLRepository}
|
||||
|
|
@ -27,6 +30,18 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
val coursierSbtResolvers = taskKey[Seq[Resolver]]("")
|
||||
|
||||
val coursierFallbackDependencies = taskKey[Seq[FallbackDependency]]("")
|
||||
|
||||
val mavenProfiles = settingKey[Set[String]]("")
|
||||
|
||||
val coursierUseSbtCredentials = settingKey[Boolean]("")
|
||||
val coursierCredentials = taskKey[Map[String, Credentials]]("")
|
||||
|
||||
val coursierCreateLogger = taskKey[CreateLogger]("")
|
||||
|
||||
val coursierCache = settingKey[File]("")
|
||||
|
||||
type CoursierCreateLogger = coursier.lmcoursier.CreateLogger
|
||||
val CoursierCreateLogger = coursier.lmcoursier.CreateLogger
|
||||
}
|
||||
|
||||
import autoImport._
|
||||
|
|
@ -37,7 +52,11 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
override def buildSettings: Seq[Setting[_]] =
|
||||
Seq(
|
||||
coursierReorderResolvers := true,
|
||||
coursierKeepPreloaded := false
|
||||
coursierKeepPreloaded := false,
|
||||
coursierUseSbtCredentials := true,
|
||||
coursierCredentials := Map.empty,
|
||||
coursierCreateLogger := CreateLogger { () => new TermDisplay(new OutputStreamWriter(System.err)) },
|
||||
coursierCache := Cache.default
|
||||
)
|
||||
|
||||
private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots"
|
||||
|
|
@ -136,7 +155,8 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
)
|
||||
|
||||
confs ++ extraSources.toSeq ++ extraDocs.toSeq
|
||||
}
|
||||
},
|
||||
mavenProfiles := Set.empty
|
||||
) ++ {
|
||||
if (pubSettings)
|
||||
IvyXml.generateIvyXmlSettings()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import coursier.{Artifact, FileError}
|
|||
import coursier.core._
|
||||
import coursier.lmcoursier._
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport.{coursierCache, coursierCreateLogger}
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ object ArtifactsTasks {
|
|||
res,
|
||||
includeSignatures,
|
||||
parallelDownloads,
|
||||
createLogger,
|
||||
createLogger.create,
|
||||
cache,
|
||||
artifactsChecksums,
|
||||
ttl,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package coursier.sbtcoursier
|
||||
|
||||
import java.io.OutputStreamWriter
|
||||
|
||||
import coursier.{Cache, CachePolicy, TermDisplay}
|
||||
import coursier.{Cache, CachePolicy}
|
||||
import coursier.core.{Configuration, ResolutionProcess}
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import sbt.{Cache => _, Configuration => _, _}
|
||||
|
|
@ -22,10 +20,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val coursierCachePolicies = Keys.coursierCachePolicies
|
||||
val coursierTtl = Keys.coursierTtl
|
||||
val coursierVerbosity = Keys.coursierVerbosity
|
||||
val mavenProfiles = Keys.mavenProfiles
|
||||
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
|
||||
val coursierCredentials = Keys.coursierCredentials
|
||||
val coursierCache = Keys.coursierCache
|
||||
val coursierConfigGraphs = Keys.coursierConfigGraphs
|
||||
val coursierSbtClassifiersModule = Keys.coursierSbtClassifiersModule
|
||||
|
||||
|
|
@ -45,8 +39,6 @@ object CoursierPlugin extends AutoPlugin {
|
|||
val coursierClassifiersArtifacts = Keys.coursierClassifiersArtifacts
|
||||
val coursierSbtClassifiersArtifacts = Keys.coursierSbtClassifiersArtifacts
|
||||
|
||||
val coursierCreateLogger = Keys.coursierCreateLogger
|
||||
|
||||
val coursierVersion = coursier.util.Properties.version
|
||||
val addSbtCoursier = {
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % coursierVersion)
|
||||
|
|
@ -194,12 +186,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
coursierArtifactsChecksums := Seq(None),
|
||||
coursierCachePolicies := CachePolicy.default,
|
||||
coursierTtl := Cache.defaultTtl,
|
||||
coursierVerbosity := Settings.defaultVerbosityLevel(sLog.value),
|
||||
mavenProfiles := Set.empty,
|
||||
coursierUseSbtCredentials := true,
|
||||
coursierCredentials := Map.empty,
|
||||
coursierCache := Cache.default,
|
||||
coursierCreateLogger := { () => new TermDisplay(new OutputStreamWriter(System.err)) }
|
||||
coursierVerbosity := Settings.defaultVerbosityLevel(sLog.value)
|
||||
)
|
||||
|
||||
override lazy val projectSettings = coursierSettings() ++
|
||||
|
|
|
|||
|
|
@ -17,17 +17,9 @@ object Keys {
|
|||
val coursierArtifactsChecksums = SettingKey[Seq[Option[String]]]("coursier-artifacts-checksums")
|
||||
val coursierCachePolicies = SettingKey[Seq[CachePolicy]]("coursier-cache-policies")
|
||||
val coursierTtl = SettingKey[Option[Duration]]("coursier-ttl")
|
||||
val coursierCreateLogger = TaskKey[() => Cache.Logger]("coursier-create-logger")
|
||||
|
||||
val coursierVerbosity = SettingKey[Int]("coursier-verbosity")
|
||||
|
||||
val mavenProfiles = SettingKey[Set[String]]("maven-profiles")
|
||||
|
||||
val coursierUseSbtCredentials = SettingKey[Boolean]("coursier-use-sbt-credentials")
|
||||
val coursierCredentials = TaskKey[Map[String, Credentials]]("coursier-credentials")
|
||||
|
||||
val coursierCache = SettingKey[File]("coursier-cache")
|
||||
|
||||
val coursierConfigGraphs = TaskKey[Seq[Set[Configuration]]]("coursier-config-graphs")
|
||||
|
||||
val coursierSbtClassifiersModule = TaskKey[GetClassifiersModule]("coursier-sbt-classifiers-module")
|
||||
|
|
|
|||
|
|
@ -1,20 +1,17 @@
|
|||
package coursier.sbtcoursier
|
||||
|
||||
import java.net.URL
|
||||
|
||||
import coursier.{Cache, ProjectCache}
|
||||
import coursier.ProjectCache
|
||||
import coursier.core._
|
||||
import coursier.extra.Typelevel
|
||||
import coursier.ivy.IvyRepository
|
||||
import coursier.lmcoursier._
|
||||
import coursier.maven.MavenRepository
|
||||
import coursier.lmcoursier.Inputs.withAuthenticationByHost
|
||||
import coursier.sbtcoursier.Keys._
|
||||
import coursier.sbtcoursiershared.InputsTasks.authenticationByHostTask
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared.autoImport._
|
||||
import sbt.Def
|
||||
import sbt.Keys._
|
||||
|
||||
import scala.util.Try
|
||||
|
||||
object ResolutionTasks {
|
||||
|
||||
def resolutionsTask(
|
||||
|
|
@ -49,34 +46,6 @@ object ResolutionTasks {
|
|||
else
|
||||
Def.task(coursierRecursiveResolvers.value.distinct)
|
||||
|
||||
val authenticationByHostTask = Def.taskDyn {
|
||||
|
||||
val useSbtCredentials = coursierUseSbtCredentials.value
|
||||
|
||||
if (useSbtCredentials)
|
||||
Def.task {
|
||||
val log = streams.value.log
|
||||
|
||||
sbt.Keys.credentials.value
|
||||
.flatMap {
|
||||
case dc: sbt.DirectCredentials => List(dc)
|
||||
case fc: sbt.FileCredentials =>
|
||||
sbt.Credentials.loadCredentials(fc.path) match {
|
||||
case Left(err) =>
|
||||
log.warn(s"$err, ignoring it")
|
||||
Nil
|
||||
case Right(dc) => List(dc)
|
||||
}
|
||||
}
|
||||
.map { c =>
|
||||
c.host -> Authentication(c.userName, c.passwd)
|
||||
}
|
||||
.toMap
|
||||
}
|
||||
else
|
||||
Def.task(Map.empty[String, Authentication])
|
||||
}
|
||||
|
||||
Def.task {
|
||||
val projectName = thisProjectRef.value.project
|
||||
|
||||
|
|
@ -141,39 +110,6 @@ object ResolutionTasks {
|
|||
.map(_.foldLeft[ProjectCache](Map.empty)(_ ++ _))
|
||||
.getOrElse(Map.empty)
|
||||
|
||||
def withAuthenticationByHost(repo: Repository, credentials: Map[String, Authentication]): Repository = {
|
||||
|
||||
def httpHost(s: String) =
|
||||
if (s.startsWith("http://") || s.startsWith("https://"))
|
||||
Try(Cache.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
|
||||
}
|
||||
}
|
||||
|
||||
val mainRepositories = resolvers
|
||||
.flatMap { resolver =>
|
||||
FromSbt.repository(
|
||||
|
|
@ -204,7 +140,7 @@ object ResolutionTasks {
|
|||
parallelDownloads,
|
||||
projectName,
|
||||
maxIterations,
|
||||
createLogger,
|
||||
createLogger.create,
|
||||
cache,
|
||||
cachePolicies,
|
||||
ttl,
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
> coursierResolutions
|
||||
|
|
@ -1 +0,0 @@
|
|||
> coursierResolutions
|
||||
|
|
@ -1 +0,0 @@
|
|||
> coursierResolutions
|
||||
|
|
@ -0,0 +1 @@
|
|||
> update
|
||||
|
|
@ -0,0 +1 @@
|
|||
> update
|
||||
|
|
@ -0,0 +1 @@
|
|||
> update
|
||||
|
|
@ -13,7 +13,7 @@ coursierCreateLogger := {
|
|||
logStream.println(msg)
|
||||
}
|
||||
val cacheFile = coursierCache.value
|
||||
;{ () =>
|
||||
;CoursierCreateLogger { () =>
|
||||
new coursier.Cache.Logger {
|
||||
override def init(beforeOutput: => Unit): Unit = {
|
||||
beforeOutput
|
||||
|
|
@ -2,11 +2,12 @@ package coursier.sbtlmcoursier
|
|||
|
||||
import coursier.core.Classifier
|
||||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||
import coursier.sbtcoursiershared.InputsTasks.authenticationByHostTask
|
||||
import coursier.sbtcoursiershared.SbtCoursierShared
|
||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||
import sbt.Project.inTask
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
object LmCoursierPlugin extends AutoPlugin {
|
||||
|
|
@ -63,15 +64,25 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
Def.task(None)
|
||||
Def.task {
|
||||
val rs = resolversTask.value
|
||||
val scalaOrg = scalaOrganization.value
|
||||
val scalaVer = scalaVersion.value
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
val excludeDeps = Inputs.exclusions(
|
||||
excludeDependencies.value,
|
||||
scalaVersion.value,
|
||||
scalaVer,
|
||||
scalaBinaryVersion.value,
|
||||
streams.value.log
|
||||
)
|
||||
val fallbackDeps = coursierFallbackDependencies.value
|
||||
val autoScalaLib = autoScalaLibrary.value
|
||||
val profiles = mavenProfiles.value
|
||||
|
||||
val authenticationByRepositoryId = coursierCredentials.value.mapValues(_.authentication)
|
||||
val authenticationByHost = authenticationByHostTask.value
|
||||
|
||||
val createLogger = coursierCreateLogger.value
|
||||
|
||||
val cache = coursierCache.value
|
||||
|
||||
val internalSbtScalaProvider = appConfiguration.value.provider.scalaProvider
|
||||
val sbtBootJars = internalSbtScalaProvider.jars()
|
||||
|
|
@ -99,6 +110,13 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
.withSbtScalaOrganization(sbtScalaOrganization)
|
||||
.withClassifiers(classifiers.toVector.flatten.map(_.value))
|
||||
.withHasClassifiers(classifiers.nonEmpty)
|
||||
.withMavenProfiles(profiles.toVector.sorted)
|
||||
.withScalaOrganization(scalaOrg)
|
||||
.withScalaVersion(scalaVer)
|
||||
.withAuthenticationByRepositoryId(authenticationByRepositoryId.toVector.sortBy(_._1))
|
||||
.withAuthenticationByHost(authenticationByHost.toVector.sortBy(_._1))
|
||||
.withCreateLogger(createLogger)
|
||||
.withCache(cache)
|
||||
.withLog(s.log)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,16 @@ runLmCoursierTests() {
|
|||
}
|
||||
|
||||
runSbtCoursierTests() {
|
||||
if [ "$TEST_GROUP" = 1 ]; then
|
||||
SCRIPTED_EXTRA="sbt-coursier/*"
|
||||
else
|
||||
SCRIPTED_EXTRA=""
|
||||
fi
|
||||
|
||||
./metadata/scripts/with-test-repo.sh sbt \
|
||||
++$TRAVIS_SCALA_VERSION \
|
||||
sbt-coursier-shared/test \
|
||||
"sbt-coursier/scripted shared-$TEST_GROUP/* sbt-coursier-group-$TEST_GROUP/*"
|
||||
"sbt-coursier/scripted shared-$TEST_GROUP/* $SCRIPTED_EXTRA"
|
||||
}
|
||||
|
||||
runSbtShadingTests() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue