1 #!/bin/bash 2 # 3 # Copyright 2013 The Android Open Source Project. 4 # 5 # Retrieves the current Objenesis source code into the current directory. 6 # Does not create a GIT commit. 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="https://github.com/easymock/objenesis" 24 INCLUDE=" 25 LICENSE.txt 26 main 27 tck 28 tck-android 29 " 30 31 EXCLUDE=" 32 main/.settings/ 33 tck-android/.settings 34 tck-android/lint.xml 35 tck-android/project.properties 36 " 37 38 working_dir="$(mktemp -d)" 39 #trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT 40 41 echo "Fetching Objenesis source into $working_dir" 42 git clone $SOURCE $working_dir/source 43 (cd $working_dir/source; git checkout $VERSION) 44 45 for include in ${INCLUDE}; do 46 echo "Updating $include" 47 rm -rf $include 48 cp -R $working_dir/source/$include . 49 done; 50 51 for exclude in ${EXCLUDE}; do 52 echo "Excluding $exclude" 53 rm -r $exclude 54 done; 55 56 # Move the tck-android AndroidManifest.xml into the correct position. 57 mv tck-android/src/main/AndroidManifest.xml tck-android/AndroidManifest.xml 58 59 # Update the version and binary JAR URL. 60 perl -pi -e "s|^Version: .*$|Version: ${VERSION}|" "README.version" 61 62 # Remove any documentation about local modifications. 63 mv README.version README.tmp 64 grep -B 100 "Local Modifications" README.tmp > README.version 65 echo " None" >> README.version 66 rm README.tmp 67 68 echo "Done" 69