Remove former shading plugin related code

Which is now unused.
This commit is contained in:
Alexandre Archambault 2020-05-19 14:30:05 +02:00
parent dabf6c8c8b
commit c82ab8850d
12 changed files with 34 additions and 109 deletions

View File

@ -189,7 +189,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
conf.sbtScalaJars
)
val configs = Inputs.coursierConfigurations(module0.configurations).map {
val configs = Inputs.coursierConfigurationsMap(module0.configurations).map {
case (k, l) =>
ToCoursier.configuration(k) -> l.map(ToCoursier.configuration)
}
@ -200,7 +200,6 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen
) =
UpdateParams(
thisModule = (ToCoursier.module(mod), ver),
shadedConfigOpt = None,
artifacts = artifacts.collect { case (d, p, a, Some(f)) => a -> f }.toMap,
fullArtifacts = Some(artifacts.map { case (d, p, a, f) => (d, p, a) -> f }.toMap),
classifiers = classifiers,

View File

@ -25,10 +25,11 @@ object Inputs {
.map(cfg => Configuration(cfg.name) -> cfg.extendsConfigs.map(c => Configuration(c.name)))
.toMap
def coursierConfigurations(
configurations: Seq[sbt.librarymanagement.Configuration],
shadedConfig: Option[(String, Configuration)] = None
): Map[Configuration, Set[Configuration]] = {
@deprecated("Use coursierConfigurationsMap instead", "2.0.0-RC6-5")
def coursierConfigurations(configurations: Seq[sbt.librarymanagement.Configuration], shadedConfigOpt: Option[String] = None): Map[Configuration, Set[Configuration]] =
coursierConfigurationsMap(configurations)
def coursierConfigurationsMap(configurations: Seq[sbt.librarymanagement.Configuration]): Map[Configuration, Set[Configuration]] = {
val configs0 = configExtendsSeq(configurations).toMap
@ -45,19 +46,10 @@ object Inputs {
helper(Set(c))
}
val map = configs0.map {
configs0.map {
case (config, _) =>
config -> allExtends(config)
}
map ++ shadedConfig.toSeq.flatMap {
case (baseConfig, shadedConfig0) =>
val baseConfig0 = Configuration(baseConfig)
Seq(
baseConfig0 -> (map.getOrElse(baseConfig0, Set(baseConfig0)) + shadedConfig0),
shadedConfig0 -> map.getOrElse(shadedConfig0, Set(shadedConfig0))
)
}
}
def orderedConfigurations(

View File

@ -9,8 +9,7 @@ object IvyXml {
def apply(
currentProject: Project,
exclusions: Seq[(String, String)],
shadedConfigOpt: Option[Configuration]
exclusions: Seq[(String, String)]
): String = {
// Important: width = Int.MaxValue, so that no tag gets truncated.
@ -22,29 +21,15 @@ object IvyXml {
val printer = new scala.xml.PrettyPrinter(Int.MaxValue, 2)
"""<?xml version="1.0" encoding="UTF-8"?>""" + '\n' +
printer.format(content(currentProject, exclusions, shadedConfigOpt))
printer.format(content(currentProject, exclusions))
}
// These are required for publish to be fine, later on.
private def content(
project0: Project,
exclusions: Seq[(String, String)],
shadedConfigOpt: Option[Configuration]
project: Project,
exclusions: Seq[(String, String)]
): Node = {
val filterOutDependencies =
shadedConfigOpt.toSet[Configuration].flatMap { shadedConfig =>
project0
.dependencies
.collect { case (conf, dep) if conf.value == shadedConfig.value => dep }
}
val project = project0.withDependencies(
project0.dependencies.collect {
case p @ (_, dep) if !filterOutDependencies(dep) => p
}
)
val props = project.module.attributes.toSeq ++ project.properties
val infoAttrs = props.foldLeft[xml.MetaData](xml.Null) {
case (acc, (k, v)) =>
@ -72,11 +57,10 @@ object IvyXml {
} % infoAttrs
val confElems = project.configurations.toVector.collect {
case (name, extends0) if !shadedConfigOpt.exists(_.value == name.value) =>
val extends1 = shadedConfigOpt.fold(extends0)(c => extends0.filter(_.value != c.value))
case (name, extends0) =>
val n = <conf name={name.value} visibility="public" description="" />
if (extends1.nonEmpty)
n % <x extends={extends1.map(_.value).mkString(",")} />.attributes
if (extends0.nonEmpty)
n % <x extends={extends0.map(_.value).mkString(",")} />.attributes
else
n
}

View File

@ -8,7 +8,6 @@ import coursier.util.Artifact
// private[coursier]
final case class UpdateParams(
thisModule: (Module, String),
shadedConfigOpt: Option[(String, Configuration)],
artifacts: Map[Artifact, File],
fullArtifacts: Option[Map[(Dependency, Publication, Artifact), Option[File]]],
classifiers: Option[Seq[Classifier]],

View File

@ -57,15 +57,7 @@ object UpdateRun {
log: Logger
): UpdateReport = Lock.lock.synchronized {
val depsByConfig = grouped(params.dependencies)(
config =>
params.shadedConfigOpt match {
case Some((baseConfig, `config`)) =>
Configuration(baseConfig)
case _ =>
config
}
)
val depsByConfig = grouped(params.dependencies)
if (verbosityLevel >= 2) {
val finalDeps = dependenciesWithConfig(
@ -94,9 +86,9 @@ object UpdateRun {
)
}
private def grouped[K, V](map: Seq[(K, V)])(mapKey: K => K): Map[K, Seq[V]] =
private def grouped[K, V](map: Seq[(K, V)]): Map[K, Seq[V]] =
map
.groupBy(t => mapKey(t._1))
.groupBy(_._1)
.mapValues(_.map(_._2))
.iterator
.toMap

View File

@ -19,7 +19,7 @@ object IvyXmlTests extends PropSpec with Matchers {
Info("", "", Nil, Nil, None)
)
val content = IvyXml(project, Nil, None)
val content = IvyXml(project, Nil)
assert(!content.contains("</conf>"))
}

View File

@ -18,7 +18,6 @@ object IvyXmlGeneration {
private def writeFiles(
currentProject: Project,
exclusions: Seq[(String, String)],
shadedConfigOpt: Option[Configuration],
ivySbt: IvySbt,
log: sbt.util.Logger
): Unit = {
@ -37,7 +36,7 @@ object IvyXmlGeneration {
val cacheIvyFile = ivyCacheManager.getResolvedIvyFileInCache(ivyModule)
val cacheIvyPropertiesFile = ivyCacheManager.getResolvedIvyPropertiesInCache(ivyModule)
val content0 = IvyXml(currentProject, exclusions, shadedConfigOpt)
val content0 = IvyXml(currentProject, exclusions)
cacheIvyFile.getParentFile.mkdirs()
log.info(s"Writing Ivy file $cacheIvyFile")
Files.write(cacheIvyFile.toPath, content0.getBytes(UTF_8))
@ -47,10 +46,7 @@ object IvyXmlGeneration {
Files.write(cacheIvyPropertiesFile.toPath, Array.emptyByteArray)
}
private def makeIvyXmlBefore[T](
task: TaskKey[T],
shadedConfigOpt: Option[Configuration]
): Setting[Task[T]] =
private def makeIvyXmlBefore[T](task: TaskKey[T]): Setting[Task[T]] =
task := task.dependsOn {
Def.taskDyn {
import SbtCoursierShared.autoImport._
@ -70,7 +66,7 @@ object IvyXmlGeneration {
case (org, name) =>
(org.value, name.value)
}
writeFiles(currentProject, excludeDeps, shadedConfigOpt, sbt.Keys.ivySbt.value, log)
writeFiles(currentProject, excludeDeps, sbt.Keys.ivySbt.value, log)
}
else
Def.task(())
@ -91,9 +87,7 @@ object IvyXmlGeneration {
Nil
}
def generateIvyXmlSettings(
shadedConfigOpt: Option[Configuration] = None
): Seq[Setting[_]] =
(needsIvyXml ++ needsIvyXmlLocal).map(makeIvyXmlBefore(_, shadedConfigOpt))
def generateIvyXmlSettings: Seq[Setting[_]] =
(needsIvyXml ++ needsIvyXmlLocal).map(makeIvyXmlBefore)
}

View File

@ -174,7 +174,7 @@ object SbtCoursierShared extends AutoPlugin {
versionReconciliation := Seq.empty
) ++ {
if (pubSettings)
IvyXmlGeneration.generateIvyXmlSettings()
IvyXmlGeneration.generateIvyXmlSettings
else
Nil
}

View File

@ -137,9 +137,7 @@ object CoursierPlugin extends AutoPlugin {
}
)
def coursierSettings(
shadedConfigOpt: Option[(String, Configuration)] = None
): Seq[Setting[_]] = hackHack ++ Seq(
def coursierSettings: Seq[Setting[_]] = hackHack ++ Seq(
coursierArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false).value,
coursierSignedArtifacts := ArtifactsTasks.artifactsTask(withClassifiers = false, includeSignatures = true).value,
coursierClassifiersArtifacts := ArtifactsTasks.artifactsTask(
@ -149,22 +147,12 @@ object CoursierPlugin extends AutoPlugin {
withClassifiers = true,
sbtClassifiers = true
).value,
update := UpdateTasks.updateTask(
shadedConfigOpt,
withClassifiers = false
).value,
updateClassifiers := UpdateTasks.updateTask(
shadedConfigOpt,
withClassifiers = true
).value,
updateSbtClassifiers.in(Defaults.TaskGlobal) := UpdateTasks.updateTask(
shadedConfigOpt,
withClassifiers = true,
sbtClassifiers = true
).value,
update := UpdateTasks.updateTask(withClassifiers = false).value,
updateClassifiers := UpdateTasks.updateTask(withClassifiers = true).value,
updateSbtClassifiers.in(Defaults.TaskGlobal) := UpdateTasks.updateTask(withClassifiers = true, sbtClassifiers = true).value,
coursierConfigGraphs := InputsTasks.ivyGraphsTask.value,
coursierSbtClassifiersModule := classifiersModule.in(updateSbtClassifiers).value,
coursierConfigurations := InputsTasks.coursierConfigurationsTask(None).value,
coursierConfigurations := InputsTasks.coursierConfigurationsTask.value,
coursierParentProjectCache := InputsTasks.parentProjectCacheTask.value,
coursierResolutions := (Def.taskDyn {
val missingOk = updateConfiguration.value.missingOk
@ -200,7 +188,7 @@ object CoursierPlugin extends AutoPlugin {
coursierVerbosity := Settings.defaultVerbosityLevel(sLog.value)
)
override lazy val projectSettings = coursierSettings() ++
override lazy val projectSettings = coursierSettings ++
inConfig(Compile)(treeSettings) ++
inConfig(Test)(treeSettings)

View File

@ -13,14 +13,9 @@ import sbt.Keys._
object InputsTasks {
def coursierConfigurationsTask(
shadedConfig: Option[(String, Configuration)]
): Def.Initialize[sbt.Task[Map[Configuration, Set[Configuration]]]] =
def coursierConfigurationsTask: Def.Initialize[sbt.Task[Map[Configuration, Set[Configuration]]]] =
Def.task {
Inputs.coursierConfigurations(ivyConfigurations.value, shadedConfig.map {
case (from, to) =>
(from, lmcoursier.definitions.Configuration(to.value))
}).map {
Inputs.coursierConfigurationsMap(ivyConfigurations.value).map {
case (k, v) =>
ToCoursier.configuration(k) -> v.map(ToCoursier.configuration)
}

View File

@ -12,7 +12,6 @@ import sbt.librarymanagement.UpdateReport
object UpdateTasks {
def updateTask(
shadedConfigOpt: Option[(String, Configuration)],
withClassifiers: Boolean,
sbtClassifiers: Boolean = false,
includeSignatures: Boolean = false
@ -57,17 +56,7 @@ object UpdateTasks {
cm.configurations.map(c => Configuration(c.name) -> Set(Configuration(c.name))).toMap
}
else
Def.task {
val configs0 = coursierConfigurations.value
shadedConfigOpt.fold(configs0) {
case (baseConfig, shadedConfig) =>
val baseConfig0 = Configuration(baseConfig)
(configs0 - shadedConfig) + (
baseConfig0 -> (configs0.getOrElse(baseConfig0, Set()) - shadedConfig)
)
}
}
coursierConfigurations
val classifiersTask: sbt.Def.Initialize[sbt.Task[Option[Seq[Classifier]]]] =
if (withClassifiers) {
@ -124,7 +113,6 @@ object UpdateTasks {
val params = UpdateParams(
(p.module, p.version),
shadedConfigOpt,
artifactFilesOrErrors0,
None,
classifiers,

View File

@ -11,13 +11,7 @@ object CoursierSbtPgpPlugin extends AutoPlugin {
override def requires = com.typesafe.sbt.SbtPgp && coursier.sbtcoursier.CoursierPlugin
override val projectSettings = Seq(
updatePgpSignatures := {
UpdateTasks.updateTask(
None,
withClassifiers = false,
includeSignatures = true
).value
}
updatePgpSignatures := UpdateTasks.updateTask(withClassifiers = false, includeSignatures = true).value
)
}