Back to home page

OSCL-LXR

 
 

    


0001 #!/usr/bin/env bash
0002 
0003 #
0004 # Licensed to the Apache Software Foundation (ASF) under one or more
0005 # contributor license agreements.  See the NOTICE file distributed with
0006 # this work for additional information regarding copyright ownership.
0007 # The ASF licenses this file to You under the Apache License, Version 2.0
0008 # (the "License"); you may not use this file except in compliance with
0009 # the License.  You may obtain a copy of the License at
0010 #
0011 #    http://www.apache.org/licenses/LICENSE-2.0
0012 #
0013 # Unless required by applicable law or agreed to in writing, software
0014 # distributed under the License is distributed on an "AS IS" BASIS,
0015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0016 # See the License for the specific language governing permissions and
0017 # limitations under the License.
0018 #
0019 
0020 set -e
0021 
0022 VALID_VERSIONS=( 2.12 2.13 )
0023 
0024 usage() {
0025   echo "Usage: $(basename $0) [-h|--help] <version>
0026 where :
0027   -h| --help Display this help text
0028   valid version values : ${VALID_VERSIONS[*]}
0029 " 1>&2
0030   exit 1
0031 }
0032 
0033 if [[ ($# -ne 1) || ( $1 == "--help") ||  $1 == "-h" ]]; then
0034   usage
0035 fi
0036 
0037 TO_VERSION=$1
0038 
0039 check_scala_version() {
0040   for i in ${VALID_VERSIONS[*]}; do [ $i = "$1" ] && return 0; done
0041   echo "Invalid Scala version: $1. Valid versions: ${VALID_VERSIONS[*]}" 1>&2
0042   exit 1
0043 }
0044 
0045 check_scala_version "$TO_VERSION"
0046 
0047 if [ $TO_VERSION = "2.13" ]; then
0048   FROM_VERSION="2.12"
0049 else
0050   FROM_VERSION="2.13"
0051 fi
0052 
0053 sed_i() {
0054   sed -e "$1" "$2" > "$2.tmp" && mv "$2.tmp" "$2"
0055 }
0056 
0057 export -f sed_i
0058 
0059 BASEDIR=$(dirname $0)/..
0060 find "$BASEDIR" -name 'pom.xml' -not -path '*target*' -print \
0061   -exec bash -c "sed_i 's/\(artifactId.*\)_'$FROM_VERSION'/\1_'$TO_VERSION'/g' {}" \;
0062 
0063 # Also update <scala.binary.version> in parent POM
0064 # Match any scala binary version to ensure idempotency
0065 sed_i '1,/<scala\.binary\.version>[0-9]*\.[0-9]*</s/<scala\.binary\.version>[0-9]*\.[0-9]*</<scala.binary.version>'$TO_VERSION'</' \
0066   "$BASEDIR/pom.xml"
0067 
0068 # Update source of scaladocs
0069 echo "$BASEDIR/docs/_plugins/copy_api_dirs.rb"
0070 sed_i 's/scala\-'$FROM_VERSION'/scala\-'$TO_VERSION'/' "$BASEDIR/docs/_plugins/copy_api_dirs.rb"