mirror of https://github.com/sbt/sbt.git
Fix corruption issues with sbt's CustomPomParser.
This commit is contained in:
parent
2011357410
commit
997037f7cd
|
|
@ -51,7 +51,15 @@ object CustomPomParser {
|
||||||
private[this] val TransformedHashKey = "e:sbtTransformHash"
|
private[this] val TransformedHashKey = "e:sbtTransformHash"
|
||||||
// A hash of the parameters transformation is based on.
|
// A hash of the parameters transformation is based on.
|
||||||
// If a descriptor has a different hash, we need to retransform it.
|
// 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))
|
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.
|
// Unfortunately, ModuleDescriptorParserRegistry is add-only and is a singleton instance.
|
||||||
|
|
@ -65,10 +73,15 @@ object CustomPomParser {
|
||||||
{
|
{
|
||||||
val oldTransformedHashKey = "sbtTransformHash"
|
val oldTransformedHashKey = "sbtTransformHash"
|
||||||
val extraInfo = md.getExtraInfo
|
val extraInfo = md.getExtraInfo
|
||||||
|
val MyHash = MakeTransformHash(md)
|
||||||
|
val h = MyHash
|
||||||
// sbt 0.13.1 used "sbtTransformHash" instead of "e:sbtTransformHash" until #1192 so read both
|
// sbt 0.13.1 used "sbtTransformHash" instead of "e:sbtTransformHash" until #1192 so read both
|
||||||
Option(extraInfo).isDefined &&
|
Option(extraInfo).isDefined &&
|
||||||
((Option(extraInfo get TransformedHashKey) orElse Option(extraInfo get oldTransformedHashKey)) match {
|
((Option(extraInfo get TransformedHashKey) orElse Option(extraInfo get oldTransformedHashKey)) match {
|
||||||
case Some(TransformHash) => true
|
case x @ Some(MyHash) =>
|
||||||
|
true
|
||||||
|
case Some(other) =>
|
||||||
|
false
|
||||||
case _ => false
|
case _ => false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -95,9 +108,9 @@ object CustomPomParser {
|
||||||
val mergeDuplicates = IvySbt.hasDuplicateDependencies(md.getDependencies)
|
val mergeDuplicates = IvySbt.hasDuplicateDependencies(md.getDependencies)
|
||||||
|
|
||||||
val unqualify = toUnqualify(filtered)
|
val unqualify = toUnqualify(filtered)
|
||||||
if (unqualify.isEmpty && extraDepAttributes.isEmpty && !convertArtifacts && !mergeDuplicates)
|
|
||||||
md
|
// Here we always add extra attributes. There's a scenario where parent-pom information corrupts child-poms with "e:" namespaced xml elements
|
||||||
else
|
// and we have to force the every generated xml file to have the appropriate xml namespace
|
||||||
addExtra(unqualify, extraDepAttributes, parser, md)
|
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.
|
// 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.
|
||||||
|
|
@ -185,7 +198,7 @@ object CustomPomParser {
|
||||||
|
|
||||||
for (l <- md.getLicenses) dmd.addLicense(l)
|
for (l <- md.getLicenses) dmd.addLicense(l)
|
||||||
for ((key, value) <- md.getExtraInfo.asInstanceOf[java.util.Map[String, String]].asScala) dmd.addExtraInfo(key, value)
|
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)
|
for ((key, value) <- md.getExtraAttributesNamespaces.asInstanceOf[java.util.Map[String, String]].asScala) dmd.addExtraAttributeNamespace(key, value)
|
||||||
IvySbt.addExtraNamespace(dmd)
|
IvySbt.addExtraNamespace(dmd)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
> cleanExampleCache
|
> cleanExampleCache
|
||||||
> update
|
> update
|
||||||
> checkIvyXml
|
> checkIvyXml
|
||||||
-> resolv
|
|
||||||
Loading…
Reference in New Issue