diff options
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy | 53 | ||||
-rw-r--r-- | buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy | 81 |
2 files changed, 0 insertions, 134 deletions
diff --git a/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy b/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy deleted file mode 100644 index 11c6a48b..00000000 --- a/buildSrc/src/main/groovy/org/apache/bigtop/BuildUtils.groovy +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.bigtop - -class BuildUtils { - - def evaluateBOM = { map, eval -> - if (eval.contains("\$(")) { - // Crazy case of using make's subst - if (eval.contains("\$(subst")) { - // Extracting name of the var from something like - // $(subst -,.,$(BIGTOP_VERSION)) - def pattern = ~ /.*\$\(subst (.*),(.*),\$\((\w+[-]?\w+?)\)\)/ - def m = eval =~ pattern - def token = "" - if (m.matches()) { - token = m[0][3] - } - 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 - def pattern = ~/\$\((\w+[-]?\w+?)\)/ - def m = eval =~ pattern - def counter = 0 - // Moving forward while matches are found - while (m.find()) { - eval = eval.replaceAll(/\$\(/, "").replaceAll(/\)/,"") - (1..m.groupCount()).each { i -> - def token = m[counter++][i] - assert map.get(token) != null - eval = eval.replaceAll(token, map.get(token)) - } - } - } - eval - } -}
\ No newline at end of file diff --git a/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy b/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy deleted file mode 100644 index 8d98c057..00000000 --- a/buildSrc/src/test/groovy/org/apache/bigtop/TestBuildUtils.groovy +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.bigtop - -import org.junit.Assert -import org.junit.Test - -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', - 'BIGTOP_BUILD_STAMP=1' - ] - Map map = [ - APACHE_MIRROR: "http://apache.osuosl.org", - APACHE_ARCHIVE: "http://archive.apache.org/dist", - ] - - @Test - void testEvaluateBOM () { - BuildUtils buildUtils = new BuildUtils() - def envs = [] - input.each { line -> - envs = line?.split("=") - 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")) - } - - @Test - void testOverrideBOM () { - System.setProperty("BIGTOP_UTILS_BASE_VERSION", "10.1.0") - System.setProperty("BIGTOP_BUILD_STAMP", "12") - System.setProperty("HADOOP_SITE", "http://www.apache.org") - BuildUtils buildUtils = new BuildUtils() - def envs = [] - input.each { line -> - envs = line?.split("=") - def value = buildUtils.evaluateBOM(map, envs[1]) - value = System.getProperty(envs[0]) ?: value - map.put(envs[0], value) - } - - Assert.assertEquals("10.1.0", map.get("BIGTOP_UTILS_BASE_VERSION")) - Assert.assertEquals("12", map.get("BIGTOP_BUILD_STAMP")) - Assert.assertEquals("http://www.apache.org", map.get("HADOOP_SITE")) - System.clearProperty("HADOOP_SITE") - System.clearProperty("BIGTOP_BUILD_STAMP") - System.clearProperty("BIGTOP_UTILS_BASE_VERSION") - } -} |