Skip to content
Permalink
Browse files
BIGTOP-1201. Enhance (gradleize) the build to ease development, deplo…
…yment; abstract implementation
  • Loading branch information
Konstantin Boudnik committed May 16, 2014
1 parent 4954aaa commit f301b9a3b497d73cf06008f06e89b4cbce74ca15
Show file tree
Hide file tree
Showing 5 changed files with 674 additions and 5 deletions.
@@ -1,11 +1,31 @@
/*
* 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.
*/
apply plugin: 'java'
apply plugin: 'maven'
// All packaging logic is separated into its own build module
apply from: 'packages.gradle'

group = 'org.apache.bigtop'
version = '0.8.0-SNAPSHOT'

description = """Bigtop"""


sourceCompatibility = 1.6
targetCompatibility = 1.6

@@ -39,9 +59,14 @@ installiTest.mustRunAfter installTopLevel
installAllLocalArtifacts.dependsOn installTopLevel, installCommon, installConf, installiTest, installTestArtifacts

repositories {
maven { url "http://mvn01.shef.wandisco.com:8081/artifactory/libs-snapshot-local" }
maven { url "http://mvn01.shef.wandisco.com:8081/artifactory/ext-snapshot-local" }
maven { url "http://mvn01.shef.wandisco.com:8081/artifactory/libs-release-local" }
maven { url "http://repository.apache.org/snapshots" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "http://repository.apache.org/snapshots" }
maven { url "http://repo.maven.apache.org/maven2" }
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'de.undercouch:gradle-download-task:1.0'
}
}
@@ -0,0 +1,52 @@
/*
* 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][1]
}
eval = map.get(token).replaceAll("-", ".")
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]
eval = eval.replaceAll(token, map.get(token))
}
}
}
eval
}
}
@@ -0,0 +1,54 @@
/*
* 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 junit.framework.Assert
import org.junit.Test

class TestBuildUtils {

def final PREFIX = "BIGTOP_UTILS"
def input = [
'BIGTOP_VERSION=0.9.0-3',
'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_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'
]
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("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"))
}
}

0 comments on commit f301b9a

Please sign in to comment.