Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | cd $(dirname $0) |
| 4 | |
| 5 | echo "IF THIS SCRIPT FIXES YOUR BUILD; OPEN A BUG." |
Jeff Gaston | cc0993d | 2019-04-02 18:02:44 -0400 | [diff] [blame^] | 6 | echo "In nearly all cases, it should not be necessary to run a clean build." |
| 7 | echo |
| 8 | echo "You may be more interested in running:" |
| 9 | echo |
| 10 | echo " ./development/diagnose-build-failure/diagnose-build-failure.sh $*" |
| 11 | echo |
| 12 | echo "which attempts to diagnose more details about build failures" |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 13 | # one case where it is convenient to have a clean build is for double-checking that a build failure isn't due to an incremental build failure |
| 14 | # another case where it is convenient to have a clean build is for performance testing |
| 15 | # another case where it is convenient to have a clean build is when you're modifying the build and may have introduced some errors but haven't shared your changes yet (at which point you should have fixed the errors) |
| 16 | echo |
| 17 | |
| 18 | goals="$@" |
| 19 | |
| 20 | function usage() { |
| 21 | echo "Usage: $0 <tasks>" |
| 22 | echo "Runs a clean build of <tasks>" |
Jeff Gaston | adffce4 | 2019-04-02 15:19:40 -0400 | [diff] [blame] | 23 | echo |
| 24 | echo "For example:" |
| 25 | echo |
| 26 | echo " $0 assembleDebug # or any other arguments you would normally give to ./gradlew" |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 27 | exit 1 |
| 28 | } |
| 29 | |
| 30 | if [ "$goals" == "" ]; then |
| 31 | usage |
| 32 | fi |
| 33 | |
Jeff Gaston | cc0993d | 2019-04-02 18:02:44 -0400 | [diff] [blame^] | 34 | function confirm() { |
| 35 | # Confirm whether the user wants to run this script instead of diagnose-build-failure.sh |
| 36 | # Recall that we already mentioned the existence of diagnose-build-failure.sh above |
| 37 | echo |
| 38 | echo "Press <Enter> to run a clean build or Ctrl-C to cancel" |
| 39 | read response |
| 40 | } |
| 41 | confirm |
| 42 | |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 43 | export OUT_DIR=../../out |
| 44 | function removeCaches() { |
Jeff Gaston | cc0993d | 2019-04-02 18:02:44 -0400 | [diff] [blame^] | 45 | echo removing caches |
Jeff Gaston | 79a43f2 | 2019-04-09 16:19:12 -0400 | [diff] [blame] | 46 | rm -rf .gradle |
George Mount | 34ddc31 | 2018-10-24 13:53:18 -0700 | [diff] [blame] | 47 | rm -rf buildSrc/.gradle |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 48 | rm -f local.properties |
George Mount | 34ddc31 | 2018-10-24 13:53:18 -0700 | [diff] [blame] | 49 | rm -rf ../../out |
Jeff Gaston | 8aa46b3 | 2018-09-27 16:14:14 -0400 | [diff] [blame] | 50 | } |
| 51 | removeCaches |
| 52 | |
| 53 | echo running build |
| 54 | GRADLE_USER_HOME=../../out ./gradlew --no-daemon $goals |