You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@edgent.apache.org by dl...@apache.org on 2017/11/21 21:45:20 UTC

[9/9] incubator-edgent-samples git commit: add update-samples-version.sh

add update-samples-version.sh

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent-samples/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent-samples/commit/adba9544
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent-samples/tree/adba9544
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent-samples/diff/adba9544

Branch: refs/heads/develop
Commit: adba95446423340177ddf9e50bd60da31fd42c77
Parents: bff0639
Author: Dale LaBossiere <dl...@us.ibm.com>
Authored: Tue Nov 21 16:32:44 2017 -0500
Committer: Dale LaBossiere <dl...@us.ibm.com>
Committed: Tue Nov 21 16:32:44 2017 -0500

----------------------------------------------------------------------
 update-samples-version.sh | 101 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent-samples/blob/adba9544/update-samples-version.sh
----------------------------------------------------------------------
diff --git a/update-samples-version.sh b/update-samples-version.sh
new file mode 100755
index 0000000..4df0036
--- /dev/null
+++ b/update-samples-version.sh
@@ -0,0 +1,101 @@
+#!/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.
+##
+################################################################################
+
+set -e
+
+# Change the version of the edgent runtime that the tooling uses
+# and/or change the version of the samples artifacts
+#
+# Generally, by default build against the (latest) edgent runtime version
+# (e.g., "1.2.0").
+# Generally, if/when it's decided to update the sample artifact versions
+# they should remain a -SNAPSHOT version.
+
+USAGE="usage: `basename $0` [--edgent-version <version>] [--samples-version <version>]"
+
+EDGENT_VER=
+if [ "${1}" = "--edgent-version" -a $# -gt 1 ] ; then
+  EDGENT_VER=$2; shift; shift
+fi
+
+SAMPLES_VER=
+if [ "${1}" = "--samples-version" -a $# -gt 1 ] ; then
+  SAMPLES_VER=$2; shift; shift
+fi
+
+if [ "${EDGENT_VER}" = "" -a "${SAMPLES_VER}" = "" ] ; then
+  echo ${USAGE}
+  exit 1;
+fi
+
+if [ $# -gt 0 ] ; then
+  echo ${USAGE}
+  exit 1;
+fi
+
+# yeah, this should be some xslt processing
+
+# update the edgent.runtime.version property
+if [ "${EDGENT_VER}" != "" ] ; then
+    echo updating the edgent.runtime.version property ...
+    POMS=`find . -name pom.xml | grep -v target`
+    POMS="${POMS} `find . -name pom.xml.template | grep -v target`"
+    for POM in ${POMS}; do
+      if [ `grep -s '<edgent.runtime.version>' ${POM}` ] ; then
+        echo updating ${POM} for edgent.runtime.version ... 
+        sed -i -e "s,<edgent.runtime.version>.*</edgent.runtime.version>,<edgent.runtime.version>${EDGENT_VER}</edgent.runtime.version>," ${POM}
+        mv ${POM}-e ${POM}~
+      fi
+    done 
+fi
+
+# update the sample artifact ids
+if [ "${SAMPLES_VER}" != "" ] ; then
+    echo updating the sample artifact versions ...
+
+    # update get-edgent-jars/pom.xml.template's artifact version
+    POM=./get-edgent-jars-project/pom.xml.template
+    echo updating ${POM} ...
+    cp ${POM} ${POM}~ 
+    awk "!done && /<version>/ { print \"  <version>${SAMPLES_VER}</version>\"; done=1; next;}; \
+         1;" < ${POM}~ >${POM}
+
+    # update the other poms
+    # skip template/pom.xml as it's artifact version never changes
+    POMS=`find . -name pom.xml | grep -v template | grep -v target`
+    for POM in ${POMS} ; do
+      echo updating ${POM} ...
+      cp ${POM} ${POM}~
+      if [ "${POM}" = "./pom.xml" ] ; then
+        # change the artifact's <version> (after the <parent> spec)
+        awk "\
+           !firstMatch && /<\/parent>/ { firstMatch=1; print \$0; next; }; \
+           firstMatch && !done && /<version>/ { print \"  <version>${SAMPLES_VER}</version>\"; done=1; next;}; \
+           1;" < ${POM}~ >${POM}
+      else
+        # change the <parent> spec's <version> (the child sample pom's artifact implicitly inherits it)
+        awk "\
+           !firstMatch && /<parent>/ { firstMatch=1; print \$0; next; }; \
+           firstMatch && !done && /<version>/ { print \"    <version>${SAMPLES_VER}</version>\"; done=1; next;}; \
+           1;" < ${POM}~ >${POM}
+      fi
+    done
+fi
\ No newline at end of file