mirror of https://github.com/sbt/sbt.git
Tweak configuration handling
This commit is contained in:
parent
a03f0ad437
commit
3b7b2ffbb7
|
|
@ -3,15 +3,14 @@ package sbt.librarymanagement.coursier
|
||||||
import java.io.{ File, OutputStreamWriter }
|
import java.io.{ File, OutputStreamWriter }
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
import scala.util.{ Success, Failure }
|
import scala.util.{ Failure, Success }
|
||||||
import scala.concurrent.ExecutionContext
|
import scala.concurrent.ExecutionContext
|
||||||
|
|
||||||
import coursier.{ Artifact, Resolution, _ }
|
import coursier.{ Artifact, Resolution, _ }
|
||||||
import coursier.util.{ Gather, Task }
|
import coursier.util.{ Gather, Task }
|
||||||
|
import sbt.internal.librarymanagement.IvySbt
|
||||||
import sbt.librarymanagement.Configurations.{ CompilerPlugin, Component, ScalaTool }
|
import sbt.librarymanagement.Configurations.{ CompilerPlugin, Component, ScalaTool }
|
||||||
import sbt.librarymanagement._
|
import sbt.librarymanagement._
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
|
|
||||||
import sjsonnew.JsonFormat
|
import sjsonnew.JsonFormat
|
||||||
import sjsonnew.support.murmurhash.Hasher
|
import sjsonnew.support.murmurhash.Hasher
|
||||||
|
|
||||||
|
|
@ -19,7 +18,8 @@ case class CoursierModuleDescriptor(
|
||||||
directDependencies: Vector[ModuleID],
|
directDependencies: Vector[ModuleID],
|
||||||
scalaModuleInfo: Option[ScalaModuleInfo],
|
scalaModuleInfo: Option[ScalaModuleInfo],
|
||||||
moduleSettings: ModuleSettings,
|
moduleSettings: ModuleSettings,
|
||||||
extraInputHash: Long
|
extraInputHash: Long,
|
||||||
|
configurations: Seq[String]
|
||||||
) extends ModuleDescriptor
|
) extends ModuleDescriptor
|
||||||
|
|
||||||
case class CoursierModuleSettings() extends ModuleSettings
|
case class CoursierModuleSettings() extends ModuleSettings
|
||||||
|
|
@ -100,7 +100,8 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
||||||
moduleSetting.dependencies,
|
moduleSetting.dependencies,
|
||||||
moduleSetting.scalaModuleInfo,
|
moduleSetting.scalaModuleInfo,
|
||||||
CoursierModuleSettings(),
|
CoursierModuleSettings(),
|
||||||
extraInputHash
|
extraInputHash,
|
||||||
|
moduleSetting.configurations.map(_.name)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,6 +135,20 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
||||||
uwconfig: UnresolvedWarningConfiguration,
|
uwconfig: UnresolvedWarningConfiguration,
|
||||||
log: Logger): Either[UnresolvedWarning, UpdateReport] = {
|
log: Logger): Either[UnresolvedWarning, UpdateReport] = {
|
||||||
|
|
||||||
|
// not sure what DependencyResolutionInterface.moduleDescriptor is for, we're handled ivy stuff anyway...
|
||||||
|
val module0 = module match {
|
||||||
|
case c: CoursierModuleDescriptor => c
|
||||||
|
case i: IvySbt#Module =>
|
||||||
|
moduleDescriptor(
|
||||||
|
i.moduleSettings match {
|
||||||
|
case c: ModuleDescriptorConfiguration => c
|
||||||
|
case other => sys.error(s"unrecognized module settings: $other")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
case _ =>
|
||||||
|
sys.error(s"unrecognized ModuleDescriptor type: $module")
|
||||||
|
}
|
||||||
|
|
||||||
if (reorderedResolvers.isEmpty) {
|
if (reorderedResolvers.isEmpty) {
|
||||||
log.error(
|
log.error(
|
||||||
"Dependency resolution is configured with an empty list of resolvers. This is unlikely to work.")
|
"Dependency resolution is configured with an empty list of resolvers. This is unlikely to work.")
|
||||||
|
|
@ -175,7 +190,7 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
||||||
.unsafeRun()
|
.unsafeRun()
|
||||||
.toMap
|
.toMap
|
||||||
|
|
||||||
toUpdateReport(resolution, localArtifacts, log)
|
toUpdateReport(resolution, module0.configurations, localArtifacts, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolution.isDone &&
|
if (resolution.isDone &&
|
||||||
|
|
@ -237,6 +252,7 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
||||||
}
|
}
|
||||||
|
|
||||||
private def toUpdateReport(resolution: Resolution,
|
private def toUpdateReport(resolution: Resolution,
|
||||||
|
configurations: Seq[String],
|
||||||
artifactFilesOrErrors0: Map[Artifact, Either[FileError, File]],
|
artifactFilesOrErrors0: Map[Artifact, Either[FileError, File]],
|
||||||
log: Logger): Either[UnresolvedWarning, UpdateReport] = {
|
log: Logger): Either[UnresolvedWarning, UpdateReport] = {
|
||||||
|
|
||||||
|
|
@ -255,13 +271,15 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
||||||
case (a, Left(_)) => a
|
case (a, Left(_)) => a
|
||||||
}.toSet
|
}.toSet
|
||||||
|
|
||||||
val depsByConfig =
|
val depsByConfig = {
|
||||||
resolution.dependencies.groupBy(_.configuration).mapValues(_.toSeq)
|
val deps = resolution.dependencies.toVector
|
||||||
|
configurations.map((_, deps)).toMap
|
||||||
|
}
|
||||||
|
|
||||||
val configurations = extractConfigurationTree
|
val configurations0 = extractConfigurationTree
|
||||||
|
|
||||||
val configResolutions =
|
val configResolutions =
|
||||||
(depsByConfig.keys ++ configurations.keys).map(k => (k, resolution)).toMap
|
(depsByConfig.keys ++ configurations0.keys).map(k => (k, resolution)).toMap
|
||||||
|
|
||||||
val sbtBootJarOverrides = Map.empty[(Module, String), File] // TODO: get correct values
|
val sbtBootJarOverrides = Map.empty[(Module, String), File] // TODO: get correct values
|
||||||
val classifiers = None // TODO: get correct values
|
val classifiers = None // TODO: get correct values
|
||||||
|
|
@ -271,7 +289,7 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
||||||
ToSbt.updateReport(
|
ToSbt.updateReport(
|
||||||
depsByConfig,
|
depsByConfig,
|
||||||
configResolutions,
|
configResolutions,
|
||||||
configurations,
|
configurations0,
|
||||||
classifiers,
|
classifiers,
|
||||||
artifactFileOpt(
|
artifactFileOpt(
|
||||||
sbtBootJarOverrides,
|
sbtBootJarOverrides,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue