mirror of https://github.com/sbt/sbt.git
Trim the whitespaces in pom.xml's properties
Maven trims the whitespaces around pom.xml's properties by default. Fixes #408
This commit is contained in:
parent
991b60ddbc
commit
6eeeb8cb66
|
|
@ -7,9 +7,18 @@ import scalaz._
|
||||||
object Pom {
|
object Pom {
|
||||||
import coursier.util.Xml._
|
import coursier.util.Xml._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns either a property's key-value pair or an error if the elem is not an element.
|
||||||
|
*
|
||||||
|
* This method trims all spaces, whereas Maven has an option to preserve them.
|
||||||
|
*
|
||||||
|
* @param elem a property element
|
||||||
|
* @return the key and the value of the property
|
||||||
|
* @see [[https://issues.apache.org/jira/browse/MNG-5380]]
|
||||||
|
*/
|
||||||
def property(elem: Node): String \/ (String, String) = {
|
def property(elem: Node): String \/ (String, String) = {
|
||||||
// Not matching with Text, which fails on scala-js if the property value has xml comments
|
// Not matching with Text, which fails on scala-js if the property value has xml comments
|
||||||
if (elem.isElement) \/-(elem.label -> elem.textContent)
|
if (elem.isElement) \/-(elem.label -> elem.textContent.trim)
|
||||||
else -\/(s"Can't parse property $elem")
|
else -\/(s"Can't parse property $elem")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
commons-codec:commons-codec:1.6:compile
|
||||||
|
commons-io:commons-io:2.1:compile
|
||||||
|
commons-logging:commons-logging:1.1.1:compile
|
||||||
|
javax.activation:activation:1.1:compile
|
||||||
|
net.jcip:jcip-annotations:1.0:compile
|
||||||
|
org.apache.httpcomponents:httpclient:4.2.6:compile
|
||||||
|
org.apache.httpcomponents:httpcore:4.2.5:compile
|
||||||
|
org.jboss.resteasy:jaxrs-api:3.0.9.Final:compile
|
||||||
|
org.jboss.resteasy:resteasy-jaxrs:3.0.9.Final:compile
|
||||||
|
org.jboss.spec.javax.annotation:jboss-annotations-api_1.1_spec:1.0.1.Final:compile
|
||||||
|
|
@ -455,6 +455,13 @@ object CentralTests extends TestSuite {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
'ignoreWhitespaces - {
|
||||||
|
resolutionCheck(
|
||||||
|
Module("org.jboss.resteasy", "resteasy-jaxrs"),
|
||||||
|
"3.0.9.Final"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
'nd4jNative - {
|
'nd4jNative - {
|
||||||
// In particular:
|
// In particular:
|
||||||
// - uses OS-based activation,
|
// - uses OS-based activation,
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,29 @@ object PomParsingTests extends TestSuite {
|
||||||
|
|
||||||
assert(result == expected)
|
assert(result == expected)
|
||||||
}
|
}
|
||||||
|
'propertyWithSpaces{
|
||||||
|
val profileNode ="""
|
||||||
|
<profile>
|
||||||
|
<id>profile1</id>
|
||||||
|
<properties>
|
||||||
|
<first.prop> value1 </first.prop>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
"""
|
||||||
|
|
||||||
|
val expected = \/-(Profile(
|
||||||
|
"profile1",
|
||||||
|
None,
|
||||||
|
Profile.Activation(Nil),
|
||||||
|
Nil,
|
||||||
|
Nil,
|
||||||
|
Map("first.prop" -> "value1")
|
||||||
|
))
|
||||||
|
|
||||||
|
val result = Pom.profile(xmlParse(profileNode).right.get)
|
||||||
|
|
||||||
|
assert(result == expected)
|
||||||
|
}
|
||||||
'beFineWithCommentsInProperties{
|
'beFineWithCommentsInProperties{
|
||||||
import scalaz._, Scalaz._
|
import scalaz._, Scalaz._
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue