mirror of https://github.com/sbt/sbt.git
Fix updateSbtClassifiers
This commit is contained in:
parent
ea8927d7b2
commit
d3bedc838f
|
|
@ -103,6 +103,34 @@ object FromSbt {
|
|||
(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 => cfg.name -> cfg.extendsConfigs.map(_.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) => (cfg.name, d)
|
||||
}
|
||||
)
|
||||
case _ =>
|
||||
p
|
||||
}
|
||||
}
|
||||
|
||||
def project(
|
||||
projectID: ModuleID,
|
||||
allDependencies: Seq[ModuleID],
|
||||
|
|
|
|||
|
|
@ -550,13 +550,7 @@ object Tasks {
|
|||
|
||||
val (currentProject, fallbackDependencies, configGraphs) =
|
||||
if (sbtClassifiers) {
|
||||
val proj = FromSbt.project(
|
||||
cm.id,
|
||||
cm.dependencies,
|
||||
cm.configurations.map(cfg => cfg.name -> cfg.extendsConfigs.map(_.name)).toMap,
|
||||
sv,
|
||||
sbv
|
||||
)
|
||||
val proj = FromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
|
||||
val fallbackDeps = FromSbt.fallbackDependencies(
|
||||
cm.dependencies,
|
||||
|
|
@ -1112,13 +1106,7 @@ object Tasks {
|
|||
|
||||
val currentProject =
|
||||
if (sbtClassifiers)
|
||||
FromSbt.project(
|
||||
cm.id,
|
||||
cm.dependencies,
|
||||
cm.configurations.map(cfg => cfg.name -> cfg.extendsConfigs.map(_.name)).toMap,
|
||||
sv,
|
||||
sbv
|
||||
)
|
||||
FromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
else
|
||||
proj.copy(publications = publications)
|
||||
|
||||
|
|
@ -1155,7 +1143,7 @@ object Tasks {
|
|||
|
||||
val configs =
|
||||
if (withClassifiers && sbtClassifiers)
|
||||
cm.configurations.map(c => c.name -> Set.empty[String]).toMap
|
||||
cm.configurations.map(c => c.name -> Set(c.name)).toMap
|
||||
else
|
||||
shadedConfigOpt.fold(configs0) {
|
||||
case (baseConfig, shadedConfig) =>
|
||||
|
|
@ -1277,13 +1265,7 @@ object Tasks {
|
|||
|
||||
val currentProject =
|
||||
if (sbtClassifiers)
|
||||
FromSbt.project(
|
||||
cm.id,
|
||||
cm.dependencies,
|
||||
cm.configurations.map(cfg => cfg.name -> cfg.extendsConfigs.map(_.name)).toMap,
|
||||
sv,
|
||||
sbv
|
||||
)
|
||||
FromSbt.sbtClassifiersProject(cm, sv, sbv)
|
||||
else
|
||||
proj.copy(publications = publications)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
import Compatibility._
|
||||
|
||||
scalaVersion := appConfiguration.value.provider.scalaProvider.version
|
||||
|
||||
lazy val updateSbtClassifiersCheck = TaskKey[Unit]("updateSbtClassifiersCheck")
|
||||
|
||||
updateSbtClassifiersCheck := {
|
||||
|
||||
val configReport = updateSbtClassifiers
|
||||
.value
|
||||
.configuration(Default)
|
||||
.getOrElse {
|
||||
throw new Exception(
|
||||
"default configuration not found in updateSbtClassifiers report"
|
||||
)
|
||||
}
|
||||
|
||||
def artifacts(org: String, name: String) = configReport
|
||||
.modules
|
||||
.collect {
|
||||
case moduleReport
|
||||
if moduleReport.module.organization == org &&
|
||||
moduleReport.module.name == name =>
|
||||
moduleReport.artifacts
|
||||
}
|
||||
.toSeq
|
||||
.flatten
|
||||
|
||||
def ensureHasArtifact(org: String, name: String) =
|
||||
assert(
|
||||
artifacts(org, name).exists(_._2.getName.endsWith("-sources.jar")),
|
||||
s"$org:$name not found"
|
||||
)
|
||||
|
||||
ensureHasArtifact("org.scala-lang", "scala-library")
|
||||
ensureHasArtifact("io.get-coursier", "coursier_" + scalaBinaryVersion.value)
|
||||
ensureHasArtifact("io.get-coursier", "sbt-coursier")
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
val pluginVersion = sys.props.getOrElse(
|
||||
"plugin.version",
|
||||
throw new RuntimeException(
|
||||
"""|The system property 'plugin.version' is not defined.
|
||||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
|
||||
)
|
||||
)
|
||||
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
object Compatibility {
|
||||
|
||||
implicit class UpdateReportOps(val rep: sbt.UpdateReport) extends AnyVal {
|
||||
def configuration(conf: sbt.Configuration) =
|
||||
rep.configuration(conf.name)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
object Compatibility
|
||||
|
|
@ -0,0 +1 @@
|
|||
> updateSbtClassifiersCheck
|
||||
Loading…
Reference in New Issue