blob: 00960bd674157df2b53ac1843198c2f8dd2a6749 [file] [log] [blame]
Jeff Gaston8aa46b32018-09-27 16:14:14 -04001#!/bin/bash
2set -e
3cd $(dirname $0)
4
5echo "IF THIS SCRIPT FIXES YOUR BUILD; OPEN A BUG."
Jeff Gastoncc0993d2019-04-02 18:02:44 -04006echo "In nearly all cases, it should not be necessary to run a clean build."
7echo
8echo "You may be more interested in running:"
9echo
10echo " ./development/diagnose-build-failure/diagnose-build-failure.sh $*"
11echo
12echo "which attempts to diagnose more details about build failures"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040013# 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)
16echo
17
18goals="$@"
19
20function usage() {
21 echo "Usage: $0 <tasks>"
22 echo "Runs a clean build of <tasks>"
Jeff Gastonadffce42019-04-02 15:19:40 -040023 echo
24 echo "For example:"
25 echo
26 echo " $0 assembleDebug # or any other arguments you would normally give to ./gradlew"
Jeff Gaston8aa46b32018-09-27 16:14:14 -040027 exit 1
28}
29
30if [ "$goals" == "" ]; then
31 usage
32fi
33
Jeff Gastoncc0993d2019-04-02 18:02:44 -040034function 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}
41confirm
42
Jeff Gaston8aa46b32018-09-27 16:14:14 -040043export OUT_DIR=../../out
44function removeCaches() {
Jeff Gastoncc0993d2019-04-02 18:02:44 -040045 echo removing caches
Jeff Gaston79a43f22019-04-09 16:19:12 -040046 rm -rf .gradle
George Mount34ddc312018-10-24 13:53:18 -070047 rm -rf buildSrc/.gradle
Jeff Gaston8aa46b32018-09-27 16:14:14 -040048 rm -f local.properties
George Mount34ddc312018-10-24 13:53:18 -070049 rm -rf ../../out
Jeff Gaston8aa46b32018-09-27 16:14:14 -040050}
51removeCaches
52
53echo running build
54GRADLE_USER_HOME=../../out ./gradlew --no-daemon $goals