mirror of https://github.com/sbt/sbt.git
Prevent tags to be split in generated Ivy XML
This commit is contained in:
parent
10c65c6062
commit
8f988d4d08
|
|
@ -219,7 +219,10 @@ lazy val doc = project
|
|||
|
||||
lazy val `sbt-coursier` = project
|
||||
.dependsOn(coreJvm, cache, extra)
|
||||
.settings(plugin)
|
||||
.settings(
|
||||
plugin,
|
||||
utest
|
||||
)
|
||||
|
||||
lazy val `sbt-pgp-coursier` = project
|
||||
.dependsOn(`sbt-coursier`)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,23 @@ import SbtCompatibility._
|
|||
|
||||
object IvyXml {
|
||||
|
||||
def rawContent(
|
||||
currentProject: Project,
|
||||
shadedConfigOpt: Option[(String, String)]
|
||||
): String = {
|
||||
|
||||
// Important: width = Int.MaxValue, so that no tag gets truncated.
|
||||
// In particular, that prevents things like <foo /> to be split to
|
||||
// <foo>
|
||||
// </foo>
|
||||
// by the pretty-printer.
|
||||
// See https://github.com/sbt/sbt/issues/3412.
|
||||
val printer = new scala.xml.PrettyPrinter(Int.MaxValue, 2)
|
||||
|
||||
"""<?xml version="1.0" encoding="UTF-8"?>""" + '\n' +
|
||||
printer.format(content(currentProject, shadedConfigOpt.map(_._2)))
|
||||
}
|
||||
|
||||
// These are required for publish to be fine, later on.
|
||||
def writeFiles(
|
||||
currentProject: Project,
|
||||
|
|
@ -32,10 +49,7 @@ object IvyXml {
|
|||
val cacheIvyFile = ivyCacheManager.getResolvedIvyFileInCache(ivyModule)
|
||||
val cacheIvyPropertiesFile = ivyCacheManager.getResolvedIvyPropertiesInCache(ivyModule)
|
||||
|
||||
val printer = new scala.xml.PrettyPrinter(80, 2)
|
||||
|
||||
val content0 = """<?xml version="1.0" encoding="UTF-8"?>""" + '\n' +
|
||||
printer.format(content(currentProject, shadedConfigOpt.map(_._2)))
|
||||
val content0 = rawContent(currentProject, shadedConfigOpt)
|
||||
cacheIvyFile.getParentFile.mkdirs()
|
||||
log.info(s"Writing Ivy file $cacheIvyFile")
|
||||
FileUtil.write(cacheIvyFile, content0.getBytes("UTF-8"))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package coursier
|
||||
|
||||
import utest._
|
||||
|
||||
object IvyXmlTests extends TestSuite {
|
||||
|
||||
val tests = TestSuite {
|
||||
"no truncation" - {
|
||||
|
||||
val project = Project(
|
||||
Module("org", "name"),
|
||||
"ver",
|
||||
Nil,
|
||||
Map(
|
||||
"foo" -> (1 to 80).map("bar" + _) // long list of configurations -> no truncation any way
|
||||
),
|
||||
None,
|
||||
Nil,
|
||||
Nil,
|
||||
Nil,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Nil,
|
||||
Info.empty
|
||||
)
|
||||
|
||||
val content = IvyXml.rawContent(project, None)
|
||||
|
||||
assert(!content.contains("</conf>"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue