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