mirror of https://github.com/sbt/sbt.git
Make an updateClassifiers-related scripted test pass
That was painful… Update depending on how https://github.com/sbt/sbt/pull/4459 goes
This commit is contained in:
parent
79cfba07ad
commit
d17a2ca03f
|
|
@ -1,8 +1,6 @@
|
|||
package coursier.sbtcoursiershared
|
||||
|
||||
import java.net.URL
|
||||
|
||||
import coursier.core.{Configuration, Module, Project, Publication}
|
||||
import coursier.core.{Configuration, Project, Publication}
|
||||
import coursier.lmcoursier.{FallbackDependency, SbtCoursierCache}
|
||||
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||
import sbt.Keys._
|
||||
|
|
@ -100,6 +98,45 @@ object SbtCoursierShared extends AutoPlugin {
|
|||
}
|
||||
},
|
||||
coursierFallbackDependencies := InputsTasks.coursierFallbackDependenciesTask.value,
|
||||
ivyConfigurations := {
|
||||
val confs = ivyConfigurations.value
|
||||
val names = confs.map(_.name).toSet
|
||||
|
||||
// Yes, adding those back in sbt 1.0. Can't distinguish between config test (whose jars with classifier tests ought to
|
||||
// be added), and sources / docs else (if their JARs are in compile, they would get added too then).
|
||||
|
||||
val extraSources =
|
||||
if (names("sources"))
|
||||
None
|
||||
else
|
||||
Some(
|
||||
sbt.Configuration.of(
|
||||
id = "Sources",
|
||||
name = "sources",
|
||||
description = "",
|
||||
isPublic = true,
|
||||
extendsConfigs = Vector.empty,
|
||||
transitive = false
|
||||
)
|
||||
)
|
||||
|
||||
val extraDocs =
|
||||
if (names("docs"))
|
||||
None
|
||||
else
|
||||
Some(
|
||||
sbt.Configuration.of(
|
||||
id = "Docs",
|
||||
name = "docs",
|
||||
description = "",
|
||||
isPublic = true,
|
||||
extendsConfigs = Vector.empty,
|
||||
transitive = false
|
||||
)
|
||||
)
|
||||
|
||||
confs ++ extraSources.toSeq ++ extraDocs.toSeq
|
||||
}
|
||||
) ++ {
|
||||
if (pubSettings)
|
||||
IvyXml.generateIvyXmlSettings()
|
||||
|
|
|
|||
|
|
@ -184,46 +184,7 @@ object CoursierPlugin extends AutoPlugin {
|
|||
},
|
||||
coursierSbtClassifiersResolution := ResolutionTasks.resolutionsTask(
|
||||
sbtClassifiers = true
|
||||
).value.head._2,
|
||||
ivyConfigurations := {
|
||||
val confs = ivyConfigurations.value
|
||||
val names = confs.map(_.name).toSet
|
||||
|
||||
// Yes, adding those back in sbt 1.0. Can't distinguish between config test (whose jars with classifier tests ought to
|
||||
// be added), and sources / docs else (if their JARs are in compile, they would get added too then).
|
||||
|
||||
val extraSources =
|
||||
if (names("sources"))
|
||||
None
|
||||
else
|
||||
Some(
|
||||
sbt.Configuration.of(
|
||||
id = "Sources",
|
||||
name = "sources",
|
||||
description = "",
|
||||
isPublic = true,
|
||||
extendsConfigs = Vector.empty,
|
||||
transitive = false
|
||||
)
|
||||
)
|
||||
|
||||
val extraDocs =
|
||||
if (names("docs"))
|
||||
None
|
||||
else
|
||||
Some(
|
||||
sbt.Configuration.of(
|
||||
id = "Docs",
|
||||
name = "docs",
|
||||
description = "",
|
||||
isPublic = true,
|
||||
extendsConfigs = Vector.empty,
|
||||
transitive = false
|
||||
)
|
||||
)
|
||||
|
||||
confs ++ extraSources.toSeq ++ extraDocs.toSeq
|
||||
}
|
||||
).value.head._2
|
||||
)
|
||||
|
||||
override lazy val buildSettings = super.buildSettings ++ Seq(
|
||||
|
|
|
|||
|
|
@ -24,8 +24,53 @@ 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue