Repository: bigtop Updated Branches: refs/heads/master f07f952fa -> b25eab6a5
BIGTOP-1801. Generalize subst pattern matching for BOM file Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/b25eab6a Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/b25eab6a Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/b25eab6a Branch: refs/heads/master Commit: b25eab6a5428b9a8677d70854c2538d8102729dc Parents: f07f952 Author: Konstantin Boudnik <c...@wandisco.com> Authored: Fri Apr 3 15:53:09 2015 -0700 Committer: Konstantin Boudnik <c...@wandisco.com> Committed: Fri Apr 3 15:53:09 2015 -0700 ---------------------------------------------------------------------- buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy | 6 +++--- .../src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/b25eab6a/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy b/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy index a17e0d7..a4b99d0 100644 --- a/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy +++ b/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy @@ -25,13 +25,13 @@ class BuildUtils { if (eval.contains("\$(subst")) { // Extracting name of the var from something like // $(subst -,.,$(BIGTOP_VERSION)) - def pattern = ~ /.*\$\(subst -,.,\$\((\w+[-]?\w+?)\)\)/ + def pattern = ~ /.*\$\(subst (-.*),(.*),\$\((\w+[-]?\w+?)\)\)/ def m = eval =~ pattern def token = "" if (m.matches()) { - token = m[0][1] + token = m[0][3] } - eval = map.get(token).replaceAll("-", ".") + eval = map.get(token).replaceAll(m[0][1], m[0][2]) return eval } // Extracting all variable names that might or not be separated by dash http://git-wip-us.apache.org/repos/asf/bigtop/blob/b25eab6a/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy b/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy index 83b8966..8d98c05 100644 --- a/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy +++ b/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy @@ -25,10 +25,13 @@ class TestBuildUtils { def final PREFIX = "BIGTOP_UTILS" def input = [ 'BIGTOP_VERSION=0.9.0-3', + 'BIGTOP_GROOVY=2.4-SNAPSHOT', 'BIGTOP_UTILS_NAME=bigtop-utils', 'BIGTOP_UTILS__RELNOTES_NAME=Bigtop-utils', 'BIGTOP_UTILS_PKG_NAME=bigtop-utils', 'BIGTOP_UTILS_BASE_VERSION=$(subst -,.,$(BIGTOP_VERSION))', + 'BIGTOP_GROOVY_BASE_VERSION=$(subst -SNAPSHOT,,$(BIGTOP_GROOVY))', + 'BIGTOP_GROOVY_BASE_VERSION=$(BIGTOP_GROOVY_BASE_VERSION)', 'BIGTOP_UTILS_PKG_VERSION=$(BIGTOP_UTILS_BASE_VERSION)', 'BIGTOP_UTILS_RELEASE_VERSION=1', 'HADOOP_SITE=$(APACHE_MIRROR)/$(BIGTOP_UTILS_RELEASE_VERSION)/hadoop-2.0.6-alpha-src.tar.gz', @@ -48,6 +51,7 @@ class TestBuildUtils { map.put(envs[0], buildUtils.evaluateBOM(map, envs[1])) } + Assert.assertEquals("2.4", map.get("BIGTOP_GROOVY_BASE_VERSION")) Assert.assertEquals("0.9.0.3", map.get("BIGTOP_UTILS_BASE_VERSION")) Assert.assertEquals("0.9.0.3", map.get("BIGTOP_UTILS_PKG_VERSION")) Assert.assertEquals("http://apache.osuosl.org/1/hadoop-2.0.6-alpha-src.tar.gz", map.get("HADOOP_SITE")) @@ -74,4 +78,4 @@ class TestBuildUtils { System.clearProperty("BIGTOP_BUILD_STAMP") System.clearProperty("BIGTOP_UTILS_BASE_VERSION") } -} \ No newline at end of file +}