mirror of https://github.com/sbt/sbt.git
Merge remote-tracking branch 'upstream/0.13' into 0.13
This commit is contained in:
commit
9010226757
|
|
@ -51,7 +51,15 @@ object CustomPomParser {
|
|||
private[this] val TransformedHashKey = "e:sbtTransformHash"
|
||||
// A hash of the parameters transformation is based on.
|
||||
// If a descriptor has a different hash, we need to retransform it.
|
||||
private[this] val TransformHash: String = hash((unqualifiedKeys ++ JarPackagings).toSeq.sorted)
|
||||
private[this] def makeCoords(mrid: ModuleRevisionId): String = s"${mrid.getOrganisation}:${mrid.getName}:${mrid.getRevision}"
|
||||
|
||||
// We now include the ModuleID in a hash, to ensure that parent-pom transformations don't corrupt child poms.
|
||||
private[this] def MakeTransformHash(md: ModuleDescriptor): String = {
|
||||
val coords: String = makeCoords(md.getModuleRevisionId)
|
||||
|
||||
hash((unqualifiedKeys ++ JarPackagings ++ Set(coords)).toSeq.sorted)
|
||||
}
|
||||
|
||||
private[this] def hash(ss: Seq[String]): String = Hash.toHex(Hash(ss.flatMap(_ getBytes "UTF-8").toArray))
|
||||
|
||||
// Unfortunately, ModuleDescriptorParserRegistry is add-only and is a singleton instance.
|
||||
|
|
@ -65,11 +73,12 @@ object CustomPomParser {
|
|||
{
|
||||
val oldTransformedHashKey = "sbtTransformHash"
|
||||
val extraInfo = md.getExtraInfo
|
||||
val MyHash = MakeTransformHash(md)
|
||||
// sbt 0.13.1 used "sbtTransformHash" instead of "e:sbtTransformHash" until #1192 so read both
|
||||
Option(extraInfo).isDefined &&
|
||||
((Option(extraInfo get TransformedHashKey) orElse Option(extraInfo get oldTransformedHashKey)) match {
|
||||
case Some(TransformHash) => true
|
||||
case _ => false
|
||||
case Some(MyHash) => true
|
||||
case _ => false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -95,10 +104,10 @@ object CustomPomParser {
|
|||
val mergeDuplicates = IvySbt.hasDuplicateDependencies(md.getDependencies)
|
||||
|
||||
val unqualify = toUnqualify(filtered)
|
||||
if (unqualify.isEmpty && extraDepAttributes.isEmpty && !convertArtifacts && !mergeDuplicates)
|
||||
md
|
||||
else
|
||||
addExtra(unqualify, extraDepAttributes, parser, md)
|
||||
|
||||
// Here we always add extra attributes. There's a scenario where parent-pom information corrupts child-poms with "e:" namespaced xml elements
|
||||
// and we have to force the every generated xml file to have the appropriate xml namespace
|
||||
addExtra(unqualify, extraDepAttributes, parser, md)
|
||||
}
|
||||
// The <properties> element of the pom is used to store additional metadata, such as for sbt plugins or for the base URL for API docs.
|
||||
// This is done because the pom XSD does not appear to allow extra metadata anywhere else.
|
||||
|
|
@ -185,7 +194,7 @@ object CustomPomParser {
|
|||
|
||||
for (l <- md.getLicenses) dmd.addLicense(l)
|
||||
for ((key, value) <- md.getExtraInfo.asInstanceOf[java.util.Map[String, String]].asScala) dmd.addExtraInfo(key, value)
|
||||
dmd.addExtraInfo(TransformedHashKey, TransformHash) // mark as transformed by this version, so we don't need to do it again
|
||||
dmd.addExtraInfo(TransformedHashKey, MakeTransformHash(md)) // mark as transformed by this version, so we don't need to do it again
|
||||
for ((key, value) <- md.getExtraAttributesNamespaces.asInstanceOf[java.util.Map[String, String]].asScala) dmd.addExtraAttributeNamespace(key, value)
|
||||
IvySbt.addExtraNamespace(dmd)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,34 @@ private[sbt] object JsonUtil {
|
|||
}
|
||||
def toLite(ur: UpdateReport): UpdateReportLite =
|
||||
UpdateReportLite(ur.configurations map { cr =>
|
||||
ConfigurationReportLite(cr.configuration, cr.details)
|
||||
ConfigurationReportLite(cr.configuration, cr.details map { oar =>
|
||||
new OrganizationArtifactReport(oar.organization, oar.name, oar.modules map { mr =>
|
||||
new ModuleReport(
|
||||
mr.module, mr.artifacts, mr.missingArtifacts, mr.status,
|
||||
mr.publicationDate, mr.resolver, mr.artifactResolver,
|
||||
mr.evicted, mr.evictedData, mr.evictedReason,
|
||||
mr.problem, mr.homepage, mr.extraAttributes,
|
||||
mr.isDefault, mr.branch, mr.configurations, mr.licenses,
|
||||
summarizeCallers(mr.callers))
|
||||
})
|
||||
})
|
||||
})
|
||||
// #1763/#2030. Caller takes up 97% of space, so we need to shrink it down,
|
||||
// but there are semantics associated with some of them.
|
||||
def summarizeCallers(callers: Seq[Caller]): Seq[Caller] =
|
||||
if (callers.isEmpty) callers
|
||||
else {
|
||||
// Use the first element to represent all callers
|
||||
val head = callers.head
|
||||
val caller = new Caller(
|
||||
head.caller, head.callerConfigurations, head.callerExtraAttributes,
|
||||
callers exists { _.isForceDependency },
|
||||
callers exists { _.isChangingDependency },
|
||||
callers exists { _.isTransitiveDependency },
|
||||
callers exists { _.isDirectlyForceDependency })
|
||||
Seq(caller)
|
||||
}
|
||||
|
||||
def fromLite(lite: UpdateReportLite, cachedDescriptor: File): UpdateReport =
|
||||
{
|
||||
val stats = new UpdateStats(0L, 0L, 0L, false)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class MakePom(val log: Logger) {
|
|||
{
|
||||
val deps = depsInConfs(module, configurations)
|
||||
makeProperties(module, deps) ++
|
||||
makeDependencies(deps, includeTypes)
|
||||
makeDependencies(deps, includeTypes, module.getAllExcludeRules)
|
||||
}
|
||||
{ makeRepositories(ivy.getSettings, allRepositories, filterRepositories) }
|
||||
</project>)
|
||||
|
|
@ -220,43 +220,65 @@ class MakePom(val log: Logger) {
|
|||
}
|
||||
val IgnoreTypes: Set[String] = Set(Artifact.SourceType, Artifact.DocType, Artifact.PomType)
|
||||
|
||||
@deprecated("Use `makeDependencies` variant which takes excludes", "0.13.9")
|
||||
def makeDependencies(dependencies: Seq[DependencyDescriptor], includeTypes: Set[String]): NodeSeq =
|
||||
makeDependencies(dependencies, includeTypes, Nil)
|
||||
|
||||
def makeDependencies(dependencies: Seq[DependencyDescriptor], includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq =
|
||||
if (dependencies.isEmpty)
|
||||
NodeSeq.Empty
|
||||
else
|
||||
<dependencies>
|
||||
{ dependencies.map(makeDependency(_, includeTypes)) }
|
||||
{ dependencies.map(makeDependency(_, includeTypes, excludes)) }
|
||||
</dependencies>
|
||||
|
||||
@deprecated("Use `makeDependency` variant which takes excludes", "0.13.9")
|
||||
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq =
|
||||
makeDependency(dependency, includeTypes, Nil)
|
||||
|
||||
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq =
|
||||
{
|
||||
val artifacts = dependency.getAllDependencyArtifacts
|
||||
val includeArtifacts = artifacts.filter(d => includeTypes(d.getType))
|
||||
if (artifacts.isEmpty) {
|
||||
val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations)
|
||||
makeDependencyElem(dependency, scope, optional, None, None)
|
||||
val configs = dependency.getModuleConfigurations
|
||||
if (configs.filterNot(Set("sources", "docs")).nonEmpty) {
|
||||
val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations)
|
||||
makeDependencyElem(dependency, scope, optional, None, None, excludes)
|
||||
} else NodeSeq.Empty
|
||||
} else if (includeArtifacts.isEmpty)
|
||||
NodeSeq.Empty
|
||||
else
|
||||
NodeSeq.fromSeq(artifacts.map(a => makeDependencyElem(dependency, a)))
|
||||
NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a, excludes)))
|
||||
}
|
||||
|
||||
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Elem =
|
||||
@deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9")
|
||||
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] =
|
||||
makeDependencyElem(dependency, artifact, Nil)
|
||||
|
||||
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor, excludes: Seq[ExcludeRule]): Option[Elem] =
|
||||
{
|
||||
val configs = artifact.getConfigurations.toList match {
|
||||
case Nil | "*" :: Nil => dependency.getModuleConfigurations
|
||||
case x => x.toArray
|
||||
}
|
||||
val (scope, optional) = getScopeAndOptional(configs)
|
||||
val classifier = artifactClassifier(artifact)
|
||||
val baseType = artifactType(artifact)
|
||||
val tpe = (classifier, baseType) match {
|
||||
case (Some(c), Some(tpe)) if Artifact.classifierType(c) == tpe => None
|
||||
case _ => baseType
|
||||
}
|
||||
makeDependencyElem(dependency, scope, optional, classifier, tpe)
|
||||
if (configs.filterNot(Set("sources", "docs")).nonEmpty) {
|
||||
val (scope, optional) = getScopeAndOptional(configs)
|
||||
val classifier = artifactClassifier(artifact)
|
||||
val baseType = artifactType(artifact)
|
||||
val tpe = (classifier, baseType) match {
|
||||
case (Some(c), Some(tpe)) if Artifact.classifierType(c) == tpe => None
|
||||
case _ => baseType
|
||||
}
|
||||
Some(makeDependencyElem(dependency, scope, optional, classifier, tpe, excludes))
|
||||
} else None
|
||||
}
|
||||
|
||||
@deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9")
|
||||
def makeDependencyElem(dependency: DependencyDescriptor, scope: Option[String], optional: Boolean, classifier: Option[String], tpe: Option[String]): Elem =
|
||||
makeDependencyElem(dependency, scope, optional, classifier, tpe, Nil)
|
||||
|
||||
def makeDependencyElem(dependency: DependencyDescriptor, scope: Option[String], optional: Boolean, classifier: Option[String], tpe: Option[String], excludes: Seq[ExcludeRule]): Elem =
|
||||
{
|
||||
val mrid = dependency.getDependencyRevisionId
|
||||
<dependency>
|
||||
|
|
@ -267,7 +289,7 @@ class MakePom(val log: Logger) {
|
|||
{ optionalElem(optional) }
|
||||
{ classifierElem(classifier) }
|
||||
{ typeElem(tpe) }
|
||||
{ exclusions(dependency) }
|
||||
{ exclusions(dependency, excludes) }
|
||||
</dependency>
|
||||
}
|
||||
|
||||
|
|
@ -317,9 +339,12 @@ class MakePom(val log: Logger) {
|
|||
(scope, opt.nonEmpty)
|
||||
}
|
||||
|
||||
def exclusions(dependency: DependencyDescriptor): NodeSeq =
|
||||
@deprecated("Use `exclusions` variant which takes excludes", "0.13.9")
|
||||
def exclusions(dependency: DependencyDescriptor): NodeSeq = exclusions(dependency, Nil)
|
||||
|
||||
def exclusions(dependency: DependencyDescriptor, excludes: Seq[ExcludeRule]): NodeSeq =
|
||||
{
|
||||
val excl = dependency.getExcludeRules(dependency.getModuleConfigurations)
|
||||
val excl = dependency.getExcludeRules(dependency.getModuleConfigurations) ++ excludes
|
||||
val (warns, excls) = IvyUtil.separate(excl.map(makeExclusion))
|
||||
if (warns.nonEmpty) log.warn(warns.mkString(IO.Newline))
|
||||
if (excls.nonEmpty) <exclusions>{ excls }</exclusions>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ package ivyint
|
|||
import java.util.Date
|
||||
import java.net.URL
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import collection.concurrent
|
||||
import collection.mutable
|
||||
import collection.immutable.ListMap
|
||||
|
|
@ -20,12 +21,19 @@ import org.apache.ivy.plugins.latest.{ ArtifactInfo => IvyArtifactInfo }
|
|||
import org.apache.ivy.plugins.matcher.{ MapMatcher, PatternMatcher }
|
||||
import Configurations.{ System => _, _ }
|
||||
import annotation.tailrec
|
||||
import scala.concurrent.duration._
|
||||
|
||||
private[sbt] object CachedResolutionResolveCache {
|
||||
def createID(organization: String, name: String, revision: String) =
|
||||
ModuleRevisionId.newInstance(organization, name, revision)
|
||||
def sbtOrgTemp = "org.scala-sbt.temp"
|
||||
def graphVersion = "0.13.8"
|
||||
def graphVersion = "0.13.9"
|
||||
val buildStartup: Long = System.currentTimeMillis
|
||||
lazy val todayStr: String = toYyyymmdd(buildStartup)
|
||||
lazy val tomorrowStr: String = toYyyymmdd(buildStartup + (1 day).toMillis)
|
||||
lazy val yesterdayStr: String = toYyyymmdd(buildStartup - (1 day).toMillis)
|
||||
def toYyyymmdd(timeSinceEpoch: Long): String = yyyymmdd.format(new Date(timeSinceEpoch))
|
||||
lazy val yyyymmdd: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
|
||||
}
|
||||
|
||||
private[sbt] class CachedResolutionResolveCache() {
|
||||
|
|
@ -137,7 +145,17 @@ private[sbt] class CachedResolutionResolveCache() {
|
|||
val staticGraphDirectory = miniGraphPath / "static"
|
||||
val dynamicGraphDirectory = miniGraphPath / "dynamic"
|
||||
val staticGraphPath = staticGraphDirectory / pathOrg / pathName / pathRevision / "graphs" / "graph.json"
|
||||
val dynamicGraphPath = dynamicGraphDirectory / logicalClock.toString / pathOrg / pathName / pathRevision / "graphs" / "graph.json"
|
||||
val dynamicGraphPath = dynamicGraphDirectory / todayStr / logicalClock.toString / pathOrg / pathName / pathRevision / "graphs" / "graph.json"
|
||||
def cleanDynamicGraph(): Unit =
|
||||
{
|
||||
val list = IO.listFiles(dynamicGraphDirectory, DirectoryFilter).toList
|
||||
list filterNot { d =>
|
||||
(d.getName == todayStr) || (d.getName == tomorrowStr) || (d.getName == yesterdayStr)
|
||||
} foreach { d =>
|
||||
log.debug(s"deleting old graphs $d...")
|
||||
IO.delete(d)
|
||||
}
|
||||
}
|
||||
def loadMiniGraphFromFile: Option[Either[ResolveException, UpdateReport]] =
|
||||
(if (staticGraphPath.exists) Some(staticGraphPath)
|
||||
else if (dynamicGraphPath.exists) Some(dynamicGraphPath)
|
||||
|
|
@ -175,6 +193,9 @@ private[sbt] class CachedResolutionResolveCache() {
|
|||
val gp = if (changing) dynamicGraphPath
|
||||
else staticGraphPath
|
||||
log.debug(s"saving minigraph to $gp")
|
||||
if (changing) {
|
||||
cleanDynamicGraph()
|
||||
}
|
||||
JsonUtil.writeUpdateReport(ur, gp)
|
||||
// limit the update cache size
|
||||
if (updateReportCache.size > maxUpdateReportCacheSize) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue