diff --git a/build.sbt b/build.sbt
index a82dc52ed..9df4c49af 100644
--- a/build.sbt
+++ b/build.sbt
@@ -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`)
diff --git a/sbt-coursier/src/main/scala/coursier/IvyXml.scala b/sbt-coursier/src/main/scala/coursier/IvyXml.scala
index 4b46d82db..515752493 100644
--- a/sbt-coursier/src/main/scala/coursier/IvyXml.scala
+++ b/sbt-coursier/src/main/scala/coursier/IvyXml.scala
@@ -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 to be split to
+ //
+ //
+ // by the pretty-printer.
+ // See https://github.com/sbt/sbt/issues/3412.
+ val printer = new scala.xml.PrettyPrinter(Int.MaxValue, 2)
+
+ """""" + '\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 = """""" + '\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"))
diff --git a/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala b/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala
new file mode 100644
index 000000000..8738a7aca
--- /dev/null
+++ b/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala
@@ -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(""))
+ }
+ }
+
+}