Repository: bigtop
Updated Branches:
  refs/heads/master bce6ad337 -> ad6349c7d


Add options to deploy Maven artifacts

This adds options that can be passed to gradle to trigger specifically enabled 
builds to deploy maven artifacts, either
to their default remote repository, or to a user defined repo ID or URI:

- doMavenDeploy: flag to trigger deployment of maven artifacts
- mavenDeploySource: flag to add 'source:jars'
- mavenRepoId: repository ID, for getting credentials from Maven settings.xml
- mavenRepoUri: location of repository. Supports S3 URIs (see note)

These can all be passed to gradle using the -P flag.

S3 repo URIs are supported, via the org.springframework.build:aws-maven build 
extension.

Signed-off-by: Evans Ye <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/ad6349c7
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/ad6349c7
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/ad6349c7

Branch: refs/heads/master
Commit: ad6349c7d8885e347dfdf8a93c70acccc3efd8a0
Parents: bce6ad3
Author: Mike Grimes <[email protected]>
Authored: Wed Sep 12 06:33:17 2018 +0200
Committer: Evans Ye <[email protected]>
Committed: Mon Sep 17 00:04:24 2018 +0800

----------------------------------------------------------------------
 .../src/common/hadoop/do-component-build        |  7 +++-
 .../src/common/hive/do-component-build          |  7 +++-
 bigtop-packages/src/extensions/aws-maven.xml    | 26 +++++++++++++
 .../src/rpm/hadoop/SPECS/hadoop.spec            |  9 ++++-
 bigtop-packages/src/rpm/hive/SPECS/hive.spec    |  5 +++
 bigtop-packages/src/scripts/maven_deploy.sh     | 41 ++++++++++++++++++++
 packages.gradle                                 | 23 +++++++++++
 7 files changed, 114 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/bigtop-packages/src/common/hadoop/do-component-build
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hadoop/do-component-build 
b/bigtop-packages/src/common/hadoop/do-component-build
index c7d4e28..2a1a634 100644
--- a/bigtop-packages/src/common/hadoop/do-component-build
+++ b/bigtop-packages/src/common/hadoop/do-component-build
@@ -126,7 +126,12 @@ fi
 # Build artifacts
 MAVEN_OPTS="-Dzookeeper.version=$ZOOKEEPER_VERSION"
 MAVEN_OPTS="$MAVEN_OPTS -DskipTests -DskipTest -DskipITs"
-mvn $ANT_OPTS $BUNDLE_SNAPPY -Pdist -Pnative -Psrc -Dtar ${MAVEN_OPTS} 
-Dtomcat.version=${BIGTOP_TOMCAT_VERSION} 
-Dtomcat.download.url="$BIGTOP_TOMCAT_DOWNLOAD_URL" install package "$@"
+
+# Include common Maven Deployment logic
+. $(dirname ${0})/maven_deploy.sh
+
+# Build artifacts
+mvn $ANT_OPTS $BUNDLE_SNAPPY -Pdist -Pnative -Psrc -Dtar ${MAVEN_OPTS} 
-Dtomcat.version=${BIGTOP_TOMCAT_VERSION} 
-Dtomcat.download.url="$BIGTOP_TOMCAT_DOWNLOAD_URL" install package 
${EXTRA_GOALS} "$@"
 mvn site site:stage ${MAVEN_OPTS} $@
 
 (cd build ; tar --strip-components=1 -xzvf  
../hadoop-dist/target/hadoop-${HADOOP_VERSION}.tar.gz)

http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/bigtop-packages/src/common/hive/do-component-build
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/hive/do-component-build 
b/bigtop-packages/src/common/hive/do-component-build
index 9223e8f..ea1b4d9 100644
--- a/bigtop-packages/src/common/hive/do-component-build
+++ b/bigtop-packages/src/common/hive/do-component-build
@@ -26,8 +26,11 @@ HIVE_MAVEN_OPTS=" -Dhbase.version=$HBASE_VERSION \
 -Dspark.version=${SPARK_VERSION}
 "
 
-export MAVEN_OPTS="-Xmx1500m -Xms1500m"
-mvn ${HIVE_MAVEN_OPTS} clean install -Pdist "$@"
+# Include common Maven Deployment logic
+. $(dirname ${0})/maven_deploy.sh
+
+export MAVEN_OPTS="${MAVEN_OPTS} -Xmx1500m -Xms1500m"
+mvn ${HIVE_MAVEN_OPTS} clean install ${EXTRA_GOALS} -Pdist "$@"
 
 mkdir -p build/dist
 tar -C build/dist --strip-components=1 -xzf 
packaging/target/apache-hive-${HIVE_VERSION}-bin.tar.gz

http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/bigtop-packages/src/extensions/aws-maven.xml
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/extensions/aws-maven.xml 
b/bigtop-packages/src/extensions/aws-maven.xml
new file mode 100644
index 0000000..bf11c0f
--- /dev/null
+++ b/bigtop-packages/src/extensions/aws-maven.xml
@@ -0,0 +1,26 @@
+<!--
+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.
+-->
+
+<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 
http://maven.apache.org/xsd/core-extensions-1.0.0.xsd";>
+  <!-- Repository on Amazon S3 -->
+  <extension>
+    <groupId>org.springframework.build</groupId>
+    <artifactId>aws-maven</artifactId>
+    <version>5.0.0.RELEASE</version>
+  </extension>
+</extensions>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec 
b/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
index 5431570..1223dea 100644
--- a/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
+++ b/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec
@@ -466,7 +466,14 @@ These projects (enumerated below) allow HDFS to be mounted 
(on most flavors of U
 # This assumes that you installed Java JDK 6 and set JAVA_HOME
 # This assumes that you installed Forrest and set FORREST_HOME
 
-env HADOOP_VERSION=%{hadoop_base_version} HADOOP_ARCH=%{hadoop_arch} bash 
%{SOURCE1}
+env \
+  HADOOP_VERSION=%{hadoop_base_version} \
+  HADOOP_ARCH=%{hadoop_arch} \
+  DO_MAVEN_DEPLOY=%{?do_maven_deploy} \
+  MAVEN_DEPLOY_SOURCE=%{?maven_deploy_source} \
+  MAVEN_REPO_ID=%{?maven_repo_id} \
+  MAVEN_REPO_URI=%{?maven_repo_uri} \
+bash %{SOURCE1}
 
 %clean
 %__rm -rf $RPM_BUILD_ROOT

http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/bigtop-packages/src/rpm/hive/SPECS/hive.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/hive/SPECS/hive.spec 
b/bigtop-packages/src/rpm/hive/SPECS/hive.spec
index cada51c..722c9e3 100644
--- a/bigtop-packages/src/rpm/hive/SPECS/hive.spec
+++ b/bigtop-packages/src/rpm/hive/SPECS/hive.spec
@@ -233,6 +233,11 @@ Init scripts for WebHcat server.
 #BIGTOP_PATCH_COMMANDS
 
 %build
+env \
+  DO_MAVEN_DEPLOY=%{?do_maven_deploy} \
+  MAVEN_DEPLOY_SOURCE=%{?maven_deploy_source} \
+  MAVEN_REPO_ID=%{?maven_repo_id} \
+  MAVEN_REPO_URI=%{?maven_repo_uri} \
 bash %{SOURCE1}
 
 #########################

http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/bigtop-packages/src/scripts/maven_deploy.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/scripts/maven_deploy.sh 
b/bigtop-packages/src/scripts/maven_deploy.sh
new file mode 100644
index 0000000..35df395
--- /dev/null
+++ b/bigtop-packages/src/scripts/maven_deploy.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# 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.
+
+if [ "${DO_MAVEN_DEPLOY}" = "true" ]; then
+
+  SCHEME=${MAVEN_REPO_URI%%:*}
+  case ${SCHEME} in
+  http | https)
+    ;;
+  s3)
+    mkdir -p ./.mvn
+    cp $(dirname ${0})/aws-maven.xml ./.mvn/extensions.xml
+    ;;
+  *)
+    echo "Unsupported URI scheme \"${SCHEME}\""
+    exit 1
+    ;;
+  esac
+
+  if [ "${MAVEN_DEPLOY_SOURCE}" = "true" ]; then
+    EXTRA_GOALS+=" source:jar"
+  fi
+  if [ ! -z "${MAVEN_REPO_URI}" ]; then
+    MAVEN_OPTS+=" 
-DaltDeploymentRepository=${MAVEN_REPO_ID:-default}::default::${MAVEN_REPO_URI}"
+  fi
+  EXTRA_GOALS+=" deploy"
+  # Conditionally add Maven extension for S3 URIs
+fi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/bigtop/blob/ad6349c7/packages.gradle
----------------------------------------------------------------------
diff --git a/packages.gradle b/packages.gradle
index 140a08b..79a0d73 100644
--- a/packages.gradle
+++ b/packages.gradle
@@ -446,6 +446,11 @@ def genTasks = { target ->
     def RELEASE_DIST = "rpmbuild --eval '%{?dist}' 
2>/dev/null".execute().text.trim().replaceAll("'",'')
     def 
SRCRPM="$PKG_OUTPUT_DIR/$PKG_NAME-${PKG_VERSION}-$BIGTOP_BUILD_STAMP${RELEASE_DIST}.src.rpm"
 
+    def final DO_MAVEN_DEPLOY = project.findProperty('doMavenDeploy') == 'true'
+    def final MAVEN_DEPLOY_SOURCE = project.findProperty('mavenDeploySource') 
== 'true'
+    def final MAVEN_REPO_ID = project.hasProperty('mavenRepoId') ? 
project.property('mavenRepoId') : 'default'
+    def final MAVEN_REPO_URI = project.hasProperty('mavenRepoUri') ? 
project.property('mavenRepoUri') : null
+
     def command = [
         '--define', "_topdir $PKG_BUILD_DIR/rpm/",
         '--define', "${NAME}_base_version $BASE_VERSION",
@@ -453,7 +458,15 @@ def genTasks = { target ->
         '--define', "${NAME}_version ${PKG_VERSION}",
         '--define', "${NAME}_release ${BIGTOP_BUILD_STAMP}%{?dist}",
         '--rebuild', SRCRPM,
+        '--define', "do_maven_deploy ${DO_MAVEN_DEPLOY}",
+        '--define', "maven_deploy_source ${MAVEN_DEPLOY_SOURCE}"
     ]
+
+   if (MAVEN_REPO_URI != null) {
+      command.addAll('--define', "maven_repo_uri ${MAVEN_REPO_URI}")
+      command.addAll('--define', "maven_repo_id ${MAVEN_REPO_ID}")
+    }
+
     exec {
       workingDir BASE_DIR
       executable 'rpmbuild'
@@ -503,6 +516,16 @@ def genTasks = { target ->
       from "${BASE_DIR}/bigtop-packages/src/templates/init.d.tmpl"
       into "$PKG_BUILD_DIR/rpm/SOURCES"
     }
+    copy {
+      from "${BASE_DIR}/bigtop-packages/src/extensions"
+      into "$PKG_BUILD_DIR/rpm/SOURCES"
+      include "*"
+    }
+    copy {
+      from "${BASE_DIR}/bigtop-packages/src/scripts"
+      into "$PKG_BUILD_DIR/rpm/SOURCES"
+      include "*"
+    }
     fileTree ("$BASE_DIR/bigtop-packages/src/common/$NAME") {
       include '**/*'
     }.copy { into "$PKG_BUILD_DIR/rpm/SOURCES" }

Reply via email to