mirror of https://github.com/sbt/sbt.git
artifact and cross-naming fixes/improvements
This commit is contained in:
parent
0ff73e5791
commit
8d797e7951
|
|
@ -290,17 +290,17 @@ private object IvySbt
|
|||
case ic: InlineConfiguration => ic.copy(module = substituteCross(ic.module, cross), dependencies = substituteCrossM(ic.dependencies, cross))
|
||||
case _ => m
|
||||
}
|
||||
private def crossName(name: String, cross: String): String =
|
||||
def crossName(name: String, cross: String): String =
|
||||
name + "_" + cross
|
||||
private def substituteCross(a: Artifact, cross: String): Artifact =
|
||||
def substituteCross(a: Artifact, cross: String): Artifact =
|
||||
a.copy(name = crossName(a.name, cross))
|
||||
private def substituteCrossA(as: Seq[Artifact], cross: String): Seq[Artifact] =
|
||||
def substituteCrossA(as: Seq[Artifact], cross: String): Seq[Artifact] =
|
||||
as.map(art => substituteCross(art, cross))
|
||||
private def substituteCrossM(ms: Seq[ModuleID], cross: String): Seq[ModuleID] =
|
||||
def substituteCrossM(ms: Seq[ModuleID], cross: String): Seq[ModuleID] =
|
||||
ms.map(m => substituteCross(m, cross))
|
||||
private def substituteCross(m: ModuleID, cross: String): ModuleID =
|
||||
def substituteCross(m: ModuleID, cross: String): ModuleID =
|
||||
if(m.crossVersion)
|
||||
m.copy(name = crossName(m.name, cross), crossVersion = false, explicitArtifacts = substituteCrossA(m.explicitArtifacts, cross))
|
||||
m.copy(name = crossName(m.name, cross), explicitArtifacts = substituteCrossA(m.explicitArtifacts, cross))
|
||||
else
|
||||
m
|
||||
|
||||
|
|
|
|||
|
|
@ -90,14 +90,24 @@ object IvyActions
|
|||
module.withModule(log) { case (ivy, md, default) =>
|
||||
val resolver = ivy.getSettings.getResolver(resolverName)
|
||||
val ivyArtifact = ivyFile map { file => (MDArtifact.newIvyArtifact(md), file) }
|
||||
val as = mapArtifacts(md, artifacts) ++ ivyArtifact.toList
|
||||
val is = crossIvyScala(module.moduleSettings)
|
||||
val as = mapArtifacts(md, is, artifacts) ++ ivyArtifact.toList
|
||||
publish(md, as, resolver, overwrite = true)
|
||||
}
|
||||
}
|
||||
def mapArtifacts(module: ModuleDescriptor, artifacts: Map[Artifact, File]): Seq[(IArtifact, File)] =
|
||||
private def crossIvyScala(moduleSettings: ModuleSettings): Option[IvyScala] =
|
||||
moduleSettings match {
|
||||
case i: InlineConfiguration if i.module.crossVersion => i.ivyScala
|
||||
case e: EmptyConfiguration if e.module.crossVersion => e.ivyScala
|
||||
case _ => None
|
||||
}
|
||||
def substituteCross(ivyScala: Option[IvyScala], artifacts: Seq[Artifact]): Seq[Artifact] =
|
||||
ivyScala match { case None => artifacts; case Some(is) => IvySbt.substituteCrossA(artifacts, is.scalaVersion) }
|
||||
def mapArtifacts(module: ModuleDescriptor, ivyScala: Option[IvyScala], artifacts: Map[Artifact, File]): Seq[(IArtifact, File)] =
|
||||
{
|
||||
val seqa = artifacts.keys.toSeq
|
||||
val zipped = seqa zip IvySbt.mapArtifacts(module, seqa)
|
||||
val rawa = artifacts.keys.toSeq
|
||||
val seqa = substituteCross(ivyScala, rawa)
|
||||
val zipped = rawa zip IvySbt.mapArtifacts(module, seqa)
|
||||
zipped map { case (a, ivyA) => (ivyA, artifacts(a)) }
|
||||
}
|
||||
/** Resolves and retrieves dependencies. 'ivyConfig' is used to produce an Ivy file and configuration.
|
||||
|
|
@ -109,7 +119,8 @@ object IvyActions
|
|||
{
|
||||
case Some(x) if !configuration.missingOk => throw x
|
||||
case _ =>
|
||||
val uReport = IvyRetrieve updateReport report
|
||||
val cachedDescriptor = ivy.getSettings.getResolutionCacheManager.getResolvedIvyFileInCache(md.getModuleRevisionId)
|
||||
val uReport = IvyRetrieve.updateReport(report, cachedDescriptor)
|
||||
configuration.retrieve match
|
||||
{
|
||||
case Some(rConf) => retrieve(ivy, uReport, rConf)
|
||||
|
|
|
|||
|
|
@ -359,12 +359,14 @@ object Artifact
|
|||
val base = if(i >= 0) name.substring(0, i) else name
|
||||
Artifact(base, extract(name, defaultType), extract(name, defaultExtension), None, Nil, Some(file.toURI.toURL))
|
||||
}
|
||||
def artifactName(module: ModuleID, artifact: Artifact): String =
|
||||
def artifactName(scalaVersion: String, module: ModuleID, artifact: Artifact): String =
|
||||
{
|
||||
import artifact._
|
||||
val classifierStr = classifier match { case None => ""; case Some(c) => "-" + c }
|
||||
artifact.name + "-" + module.revision + classifierStr + "." + artifact.extension
|
||||
val base = if(module.crossVersion) IvySbt.crossName(artifact.name, scalaVersion) else artifact.name
|
||||
base + "-" + module.revision + classifierStr + "." + artifact.extension
|
||||
}
|
||||
def cross(enable: Boolean, scalaVersion: String): String = if(enable) "_" + scalaVersion else ""
|
||||
}
|
||||
final case class ModuleConfiguration(organization: String, name: String, revision: String, resolver: Resolver)
|
||||
object ModuleConfiguration
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ object IvyRetrieve
|
|||
Artifact(getName, getType, getExt, Option(getExtraAttribute("classifier")), getConfigurations map Configurations.config, Option(getUrl))
|
||||
}
|
||||
|
||||
def updateReport(report: ResolveReport): UpdateReport =
|
||||
new UpdateReport(reports(report) map configurationReport)
|
||||
def updateReport(report: ResolveReport, cachedDescriptor: File): UpdateReport =
|
||||
new UpdateReport(cachedDescriptor, reports(report) map configurationReport)
|
||||
|
||||
def configurationReport(confReport: ConfigurationResolveReport): ConfigurationReport =
|
||||
new ConfigurationReport(confReport.getConfiguration, moduleReports(confReport))
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ package sbt
|
|||
/** Provides information about dependency resolution.
|
||||
* It does not include information about evicted modules, only about the modules ultimately selected by the conflict manager.
|
||||
* This means that for a given configuration, there should only be one revision for a given organization and module name.
|
||||
* @param cachedDescriptor the location of the resolved module descriptor in the cache
|
||||
* @param configurations a sequence containing one report for each configuration resolved.
|
||||
* @see sbt.RichUpdateReport
|
||||
*/
|
||||
final class UpdateReport(val configurations: Seq[ConfigurationReport])
|
||||
final class UpdateReport(val cachedDescriptor: File, val configurations: Seq[ConfigurationReport])
|
||||
{
|
||||
override def toString = "Update report:\n" + configurations.mkString
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ final class UpdateReport(val configurations: Seq[ConfigurationReport])
|
|||
def allModules: Seq[ModuleID] = configurations.flatMap(_.allModules).distinct
|
||||
|
||||
def retrieve(f: (String, ModuleID, Artifact, File) => File): UpdateReport =
|
||||
new UpdateReport(configurations map { _ retrieve f} )
|
||||
new UpdateReport(cachedDescriptor, configurations map { _ retrieve f} )
|
||||
|
||||
/** Gets the report for the given configuration, or `None` if the configuration was not resolved.*/
|
||||
def configuration(s: String) = configurations.find(_.configuration == s)
|
||||
|
|
@ -99,7 +100,7 @@ object UpdateReport
|
|||
}
|
||||
new ConfigurationReport(configuration, newModules)
|
||||
}
|
||||
new UpdateReport(newConfigurations)
|
||||
new UpdateReport(report.cachedDescriptor, newConfigurations)
|
||||
}
|
||||
def substitute(f: (String, ModuleID, Seq[(Artifact, File)]) => Seq[(Artifact, File)]): UpdateReport =
|
||||
{
|
||||
|
|
@ -112,7 +113,7 @@ object UpdateReport
|
|||
}
|
||||
new ConfigurationReport(configuration, newModules)
|
||||
}
|
||||
new UpdateReport(newConfigurations)
|
||||
new UpdateReport(report.cachedDescriptor, newConfigurations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue