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. 9 set -e 10 11 if [ $# -ne 1 ]; then 12 echo "$0 <version>" >&2 13 exit 1; 14 fi 15 16 if [ -z "$ANDROID_BUILD_TOP" ]; then 17 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2 18 exit 1 19 fi 20 21 VERSION=${1} 22 23 SOURCE="git://github.com/mockito/mockito.git" 24 INCLUDE=" 25 LICENSE 26 src 27 subprojects/android 28 " 29 30 EXCLUDE=" 31 src/conf 32 src/javadoc 33 " 34 35 working_dir="$(mktemp -d)" 36 trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT 37 38 echo "Fetching Mockito source into $working_dir" 39 git clone $SOURCE $working_dir/source 40 (cd $working_dir/source; git checkout $VERSION) 41 42 for 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 47 done; 48 49 for exclude in ${EXCLUDE}; do 50 echo "Excluding $exclude" 51 rm -r $exclude 52 done; 53 54 echo "Done" 55 56 # Update the version. 57 perl -pi -e "s|^Version: .*$|Version: ${VERSION}|" "README.version" 58 59 # Remove any documentation about local modifications. 60 mv README.version README.tmp 61 grep -B 100 "Local Modifications" README.tmp > README.version 62 echo " None" >> README.version 63 rm README.tmp 64 65 echo "Done" 66