1#!/bin/bash 2# 3# Copyright 2013 The Android Open Source Project. 4# 5# Retrieves the current Mockito source code into the current directory, excluding portions related 6# to mockito's internal build system and javadoc. 7 8# Force stop on first error. 9set -e 10 11if [ $# -ne 1 ]; then 12 echo "$0 <version>" >&2 13 exit 1; 14fi 15 16if [ -z "$ANDROID_BUILD_TOP" ]; then 17 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2 18 exit 1 19fi 20 21VERSION=${1} 22 23SOURCE="git://github.com/mockito/mockito.git" 24INCLUDE=" 25 LICENSE 26 src 27 subprojects/android 28 " 29 30EXCLUDE=" 31 src/conf 32 src/javadoc 33 " 34 35working_dir="$(mktemp -d)" 36trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT 37 38echo "Fetching Mockito source into $working_dir" 39git clone $SOURCE $working_dir/source 40(cd $working_dir/source; git checkout $VERSION) 41 42for include in ${INCLUDE}; do 43 echo "Updating $include" 44 rm -rf $include 45 mkdir -p $(dirname $include) 46 cp -R $working_dir/source/$include $include 47done; 48 49for exclude in ${EXCLUDE}; do 50 echo "Excluding $exclude" 51 rm -r $exclude 52done; 53 54echo "Done" 55 56# Update the version. 57perl -pi -e "s|^Version: .*$|Version: ${VERSION}|" "README.version" 58 59# Remove any documentation about local modifications. 60mv README.version README.tmp 61grep -B 100 "Local Modifications" README.tmp > README.version 62echo " None" >> README.version 63rm README.tmp 64 65echo "Done" 66