mirror of https://github.com/sbt/sbt.git
Does this break anything? Let's see!!
This commit is contained in:
parent
d17a2ca03f
commit
da58ebdaf8
|
|
@ -16,22 +16,24 @@ final class CoursierConfiguration private (
|
|||
val interProjectDependencies: Vector[coursier.core.Project],
|
||||
val excludeDependencies: Vector[(String, String)],
|
||||
val fallbackDependencies: Vector[coursier.lmcoursier.FallbackDependency],
|
||||
val autoScalaLibrary: Boolean) extends Serializable {
|
||||
val autoScalaLibrary: Boolean,
|
||||
val hasClassifiers: Boolean,
|
||||
val classifiers: Vector[String]) 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)
|
||||
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)
|
||||
|
||||
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)
|
||||
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 _ => false
|
||||
}
|
||||
override def hashCode: Int = {
|
||||
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.##)
|
||||
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.##)
|
||||
}
|
||||
override def toString: String = {
|
||||
"CoursierConfiguration(" + log + ", " + resolvers + ", " + reorderResolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ", " + autoScalaLibrary + ")"
|
||||
"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): CoursierConfiguration = {
|
||||
new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary)
|
||||
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)
|
||||
}
|
||||
def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = {
|
||||
copy(log = log)
|
||||
|
|
@ -78,10 +80,16 @@ final class CoursierConfiguration private (
|
|||
def withAutoScalaLibrary(autoScalaLibrary: Boolean): CoursierConfiguration = {
|
||||
copy(autoScalaLibrary = autoScalaLibrary)
|
||||
}
|
||||
def withHasClassifiers(hasClassifiers: Boolean): CoursierConfiguration = {
|
||||
copy(hasClassifiers = hasClassifiers)
|
||||
}
|
||||
def withClassifiers(classifiers: Vector[String]): CoursierConfiguration = {
|
||||
copy(classifiers = classifiers)
|
||||
}
|
||||
}
|
||||
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): CoursierConfiguration = new CoursierConfiguration(log, resolvers, reorderResolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary)
|
||||
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): CoursierConfiguration = new CoursierConfiguration(Option(log), resolvers, reorderResolvers, parallelDownloads, maxIterations, Option(sbtScalaOrganization), Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary)
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,18 @@
|
|||
"type": "Boolean",
|
||||
"default": "true",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "hasClassifiers",
|
||||
"type": "Boolean",
|
||||
"default": "false",
|
||||
"since": "0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "classifiers",
|
||||
"type": "String*",
|
||||
"default": "Vector.empty",
|
||||
"since": "0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package coursier.lmcoursier
|
|||
import java.io.{File, OutputStreamWriter}
|
||||
|
||||
import _root_.coursier.{Artifact, Cache, CachePolicy, FileError, Organization, Resolution, TermDisplay, organizationString}
|
||||
import _root_.coursier.core.{Configuration, ModuleName}
|
||||
import _root_.coursier.core.{Classifier, Configuration, ModuleName}
|
||||
import _root_.coursier.ivy.IvyRepository
|
||||
import sbt.internal.librarymanagement.IvySbt
|
||||
import sbt.librarymanagement._
|
||||
|
|
@ -74,6 +74,12 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
|
||||
val ivyProperties = ResolutionParams.defaultIvyProperties()
|
||||
|
||||
val classifiers =
|
||||
if (conf.hasClassifiers)
|
||||
Some(conf.classifiers.map(Classifier(_)))
|
||||
else
|
||||
None
|
||||
|
||||
val mainRepositories = resolvers
|
||||
.flatMap { resolver =>
|
||||
FromSbt.repository(
|
||||
|
|
@ -143,7 +149,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
|
||||
def artifactsParams(resolutions: Map[Set[Configuration], Resolution]) =
|
||||
ArtifactsParams(
|
||||
classifiers = None,
|
||||
classifiers = classifiers,
|
||||
res = resolutions.values.toSeq,
|
||||
includeSignatures = false,
|
||||
parallelDownloads = conf.parallelDownloads,
|
||||
|
|
@ -171,7 +177,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
|
|||
UpdateParams(
|
||||
shadedConfigOpt = None,
|
||||
artifacts = artifacts,
|
||||
classifiers = None,
|
||||
classifiers = classifiers,
|
||||
configs = configs,
|
||||
dependencies = dependencies,
|
||||
res = resolutions,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package coursier.sbtlmcoursier
|
||||
|
||||
import coursier.core.Classifier
|
||||
import coursier.lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||
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, updateSbtClassifiers}
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
object LmCoursierPlugin extends AutoPlugin {
|
||||
|
|
@ -24,56 +25,21 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
// so that it doesn't override us :|
|
||||
override def requires = SbtCoursierShared
|
||||
|
||||
private val temporarySettings = {
|
||||
|
||||
import sbt._
|
||||
import sbt.Classpaths.withExcludes
|
||||
import sbt.Defaults.lock
|
||||
import sbt.Keys._
|
||||
import sbt.librarymanagement.GetClassifiersConfiguration
|
||||
|
||||
Seq(
|
||||
// cut-n-pasted from sbt 1.0.2
|
||||
// only the "val lm = …" line was changed
|
||||
updateClassifiers := (Def.task {
|
||||
val s = streams.value
|
||||
val is = ivySbt.value
|
||||
val lm = dependencyResolution.value
|
||||
val mod = (classifiersModule in updateClassifiers).value
|
||||
val c = updateConfiguration.value
|
||||
val app = appConfiguration.value
|
||||
val srcTypes = sourceArtifactTypes.value
|
||||
val docTypes = docArtifactTypes.value
|
||||
val out = is.withIvy(s.log)(_.getSettings.getDefaultIvyUserDir)
|
||||
val uwConfig = (unresolvedWarningConfiguration in update).value
|
||||
withExcludes(out, mod.classifiers, lock(app)) { excludes =>
|
||||
lm.updateClassifiers(
|
||||
GetClassifiersConfiguration(
|
||||
mod,
|
||||
excludes.toVector,
|
||||
c.withArtifactFilter(c.artifactFilter.map(af => af.withInverted(!af.inverted))),
|
||||
// scalaModule,
|
||||
srcTypes.toVector,
|
||||
docTypes.toVector
|
||||
),
|
||||
uwConfig,
|
||||
Vector.empty,
|
||||
s.log
|
||||
) match {
|
||||
case Left(_) => ???
|
||||
case Right(ur) => ur
|
||||
}
|
||||
}
|
||||
} tag (Tags.Update, Tags.Network)).value
|
||||
)
|
||||
}
|
||||
|
||||
// putting this in projectSettings like sbt.plugins.IvyPlugin does :|
|
||||
override def projectSettings: Seq[Setting[_]] =
|
||||
temporarySettings ++
|
||||
Seq(
|
||||
dependencyResolution := mkDependencyResolution.value,
|
||||
coursierConfiguration := mkCoursierConfiguration().value
|
||||
coursierConfiguration := mkCoursierConfiguration().value,
|
||||
updateClassifiers := Def.taskDyn {
|
||||
val lm = dependencyResolution.in(updateClassifiers).value
|
||||
Def.task(sbt.hack.Foo.updateTask(lm).value)
|
||||
}.value
|
||||
) ++
|
||||
inTask(updateClassifiers)(
|
||||
Seq(
|
||||
dependencyResolution := mkDependencyResolution.value,
|
||||
coursierConfiguration := mkCoursierConfiguration(withClassifiers = true).value
|
||||
)
|
||||
) ++
|
||||
inTask(updateSbtClassifiers)(
|
||||
Seq(
|
||||
|
|
@ -83,13 +49,18 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
)
|
||||
|
||||
|
||||
private def mkCoursierConfiguration(sbtClassifiers: Boolean = false): Def.Initialize[Task[CoursierConfiguration]] =
|
||||
private def mkCoursierConfiguration(withClassifiers: Boolean = false, sbtClassifiers: Boolean = false): Def.Initialize[Task[CoursierConfiguration]] =
|
||||
Def.taskDyn {
|
||||
val resolversTask =
|
||||
if (sbtClassifiers)
|
||||
coursierSbtResolvers
|
||||
else
|
||||
coursierRecursiveResolvers
|
||||
val classifiersTask: sbt.Def.Initialize[sbt.Task[Option[Seq[Classifier]]]] =
|
||||
if (withClassifiers && !sbtClassifiers)
|
||||
Def.task(Some(sbt.Keys.transitiveClassifiers.value.map(Classifier(_))))
|
||||
else
|
||||
Def.task(None)
|
||||
Def.task {
|
||||
val rs = resolversTask.value
|
||||
val interProjectDependencies = coursierInterProjectDependencies.value
|
||||
|
|
@ -106,6 +77,7 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
val sbtBootJars = internalSbtScalaProvider.jars()
|
||||
val sbtScalaVersion = internalSbtScalaProvider.version()
|
||||
val sbtScalaOrganization = "org.scala-lang" // always assuming sbt uses mainline scala
|
||||
val classifiers = classifiersTask.value
|
||||
val s = streams.value
|
||||
Classpaths.warnResolversConflict(rs, s.log)
|
||||
CoursierConfiguration()
|
||||
|
|
@ -125,6 +97,8 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
.withSbtScalaJars(sbtBootJars.toVector)
|
||||
.withSbtScalaVersion(sbtScalaVersion)
|
||||
.withSbtScalaOrganization(sbtScalaOrganization)
|
||||
.withClassifiers(classifiers.toVector.flatten.map(_.value))
|
||||
.withHasClassifiers(classifiers.nonEmpty)
|
||||
.withLog(s.log)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
package sbt.hack
|
||||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import sbt.internal.LibraryManagement
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
object Foo {
|
||||
|
||||
// same implementation as update in sbt, except DependencyResolution is passed as argument
|
||||
// and the unmanagedJarsTask stuff was removed (already handled in lm-coursier via
|
||||
// SbtBootJars and all)
|
||||
def updateTask(lm: DependencyResolution): Def.Initialize[Task[UpdateReport]] = Def.task {
|
||||
val s = streams.value
|
||||
val cacheDirectory = streams.value.cacheDirectory
|
||||
|
||||
val isRoot = executionRoots.value contains resolvedScoped.value
|
||||
val shouldForce = isRoot || {
|
||||
forceUpdatePeriod.value match {
|
||||
case None => false
|
||||
case Some(period) =>
|
||||
val fullUpdateOutput = cacheDirectory / "out"
|
||||
val now = System.currentTimeMillis
|
||||
val diff = now - fullUpdateOutput.lastModified()
|
||||
val elapsedDuration = new scala.concurrent.duration.FiniteDuration(diff, java.util.concurrent.TimeUnit.MILLISECONDS)
|
||||
fullUpdateOutput.exists() && elapsedDuration > period
|
||||
}
|
||||
}
|
||||
|
||||
val state0 = state.value
|
||||
val updateConf = {
|
||||
// Log captures log messages at all levels, except ivy logs.
|
||||
// Use full level when debug is enabled so that ivy logs are shown.
|
||||
import UpdateLogging.{ Full, DownloadOnly, Default }
|
||||
val conf = updateConfiguration.value
|
||||
val maybeUpdateLevel = (logLevel in update).?.value
|
||||
val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match {
|
||||
case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full)
|
||||
case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly)
|
||||
case _ => conf
|
||||
}
|
||||
|
||||
// logical clock is folded into UpdateConfiguration
|
||||
conf1.withLogicalClock(LogicalClock(state0.hashCode))
|
||||
}
|
||||
|
||||
val evictionOptions = Def.taskDyn {
|
||||
if (executionRoots.value.exists(_.key == evicted.key))
|
||||
Def.task(EvictionWarningOptions.empty)
|
||||
else Def.task((evictionWarningOptions in update).value)
|
||||
}.value
|
||||
|
||||
LibraryManagement.cachedUpdate(
|
||||
// LM API
|
||||
lm = lm,
|
||||
// Ivy-free ModuleDescriptor
|
||||
module = ivyModule.value,
|
||||
s.cacheStoreFactory.sub(updateCacheName.value),
|
||||
Reference.display(thisProjectRef.value),
|
||||
updateConf,
|
||||
identity,
|
||||
skip = (skip in update).value,
|
||||
force = shouldForce,
|
||||
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
|
||||
uwConfig = (unresolvedWarningConfiguration in update).value,
|
||||
ewo = evictionOptions,
|
||||
mavenStyle = publishMavenStyle.value,
|
||||
compatWarning = compatibilityWarningOptions.value,
|
||||
log = s.log
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue