aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-04-08 18:29:21 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2016-04-08 18:30:06 -0400
commit0f8fcb91a28d931131c7f876c7d73f9bb837b4fe (patch)
tree2d089d5ac99494ad2d4e5c7f81abdf7e177906b1
parent5fdfbf662cad2b00ed68729318dbb3a7e3c67ba3 (diff)
downloadcbt-0f8fcb91a28d931131c7f876c7d73f9bb837b4fe.tar.gz
cbt-0f8fcb91a28d931131c7f876c7d73f9bb837b4fe.tar.bz2
cbt-0f8fcb91a28d931131c7f876c7d73f9bb837b4fe.zip
Allow substituting POM variables inside of strings, not only entire elements
-rw-r--r--stage1/resolver.scala18
-rw-r--r--test/simple/build/build.scala4
2 files changed, 14 insertions, 8 deletions
diff --git a/stage1/resolver.scala b/stage1/resolver.scala
index e4af8a9..694bd83 100644
--- a/stage1/resolver.scala
+++ b/stage1/resolver.scala
@@ -402,10 +402,12 @@ case class BoundMavenDependency(
def lookup( xml: Node, accessor: Node => NodeSeq ): Option[String] = {
//println("lookup in "++pomUrl)
val Substitution = "\\$\\{([^\\}]+)\\}".r
- accessor(xml).headOption.flatMap{v =>
+ accessor(xml).headOption.map{v =>
//println("found: "++v.text)
- v.text match {
- case Substitution(path) => Option(
+ Substitution.replaceAllIn(
+ v.text,
+ matcher => {
+ val path = matcher.group(1)
properties.get(path).orElse(
transitivePom.reverse.flatMap{ d =>
Some(path.split("\\.").toList).collect{
@@ -414,10 +416,12 @@ case class BoundMavenDependency(
}.filter(_ != "")
}.headOption
)
- .getOrElse( throw new Exception(s"Can't find $path in \n$properties.\n\npomParents: $transitivePom\n\n pomXml:\n$pomXml" )))
- //println("lookup "++path ++ ": "++(pomXml\path).text)
- case value => Option(value)
- }
+ .getOrElse(
+ throw new Exception(s"Can't find $path in \n$properties.\n\npomParents: $transitivePom\n\n pomXml:\n$pomXml" )
+ )
+ //println("lookup "++path ++ ": "++(pomXml\path).text)
+ }
+ )
}
}
}
diff --git a/test/simple/build/build.scala b/test/simple/build/build.scala
index 31f2ab9..173c1da 100644
--- a/test/simple/build/build.scala
+++ b/test/simple/build/build.scala
@@ -14,7 +14,9 @@ class Build(context: cbt.Context) extends BasicBuild(context){
// the below tests pom inheritance with dependencyManagement and variable substitution for pom properties
MavenDependency("org.eclipse.jgit", "org.eclipse.jgit", "4.2.0.201601211800-r"),
// the below tests pom inheritance with variable substitution for pom xml tag contents
- MavenDependency("com.spotify", "missinglink-core", "0.1.1")
+ MavenDependency("com.spotify", "missinglink-core", "0.1.1"),
+ // the below tests pom inheritance with variable substitution being parts of strings
+ MavenDependency("cc.factorie","factorie_2.11","1.2")
),
MavenRepository.combine(
MavenRepository.central,