Skip to content

Commit 0a679d3

Browse files
committed
tools: Add Gradle runner, to avoid cd android
And simplify various scripts and docs accordingly.
1 parent 0fc2486 commit 0a679d3

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to upgrade Gradle:
2-
# $ ./gradlew wrapper --distribution-type=all --gradle-version=NEW_VERSION
3-
# $ ./gradlew wrapper --distribution-type=all --gradle-version=NEW_VERSION
2+
# $ tools/gradle wrapper --distribution-type=all --gradle-version=NEW_VERSION
3+
# $ tools/gradle wrapper --distribution-type=all --gradle-version=NEW_VERSION
44
# (Yep, run the same command twice. The first updates this file so we use
55
# the new Gradle; the second updates the wrapper's jar and scripts, so that
66
# the wrapper is the one from the new Gradle too.)

docs/howto/build-run.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ java.nio.file.NoSuchFileException: /Users/chrisbobbe/dev/zulip-mobile/android/ap
280280
at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:407)
281281
```
282282

283-
Try removing `android/.gradle`, running `./gradlew clean` from
284-
`android/`, and building again.
283+
Try removing `android/.gradle`, running `tools/gradle clean`,
284+
and building again.
285285

286286
### Build failure: No file known for: classes.dex
287287

@@ -293,8 +293,8 @@ Execution failed for task ':app:packageDebug'.
293293
> No file known for: classes.dex
294294
```
295295

296-
Try removing `android/.gradle`, running `./gradlew clean` from
297-
`android/`, and building again.
296+
Try removing `android/.gradle`, running `tools/gradle clean`,
297+
and building again.
298298

299299
### Build failure: java.lang.UnsupportedClassVersionError, "Unsupported major.minor version 52.0"
300300

@@ -343,7 +343,7 @@ Could not compile build file '/Users/chrisbobbe/dev/zulip-mobile/node_modules/@u
343343
This can sometimes happen if you're using JDK 13 to invoke the build
344344
command (e.g., when calling `tools/run-android`, or
345345
`tools/test native`, or
346-
`android/gradlew -p android :app:assembleDebug`). You can check the
346+
`tools/gradle :app:assembleDebug`). You can check the
347347
version by running `java -version`. It seems that upgrading to
348348
macOS 10.15 Catalina automatically upgrades Java to 13.
349349

@@ -686,7 +686,7 @@ Sometimes, the build cache from previous builds can cause issues, and cleaning
686686
it can help:
687687

688688
```
689-
cd android && ./gradlew clean
689+
tools/gradle clean
690690
```
691691

692692
Optionally, reset iOS simulator:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"android": "tools/run-android",
1010
"android-release": "react-native run-android --variant=release",
1111
"build:android": "tools/android apk",
12-
"build:android-nokeys": "cd android && ./gradlew :app:assembleRelease",
12+
"build:android-nokeys": "tools/gradle :app:assembleRelease",
1313
"build:ios": "cd ios && xcodebuild -scheme ZulipMobile archivexcodebuild -scheme ZulipMobile archive",
1414
"test": "tools/test",
1515
"prettier": "tools/fmt",

tools/android

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ do_apk() {
6464
check_yarn_link
6565
run_visibly yarn
6666

67-
run_visibly android/gradlew -p android :app:assembleRelease -Psigned -Psentry
67+
run_visibly tools/gradle :app:assembleRelease -Psigned -Psentry
6868
}
6969

7070
do_aab() {
7171
check_yarn_link
7272
run_visibly yarn
7373

74-
run_visibly android/gradlew -p android :app:bundleRelease -Psigned -Psentry
74+
run_visibly tools/gradle :app:bundleRelease -Psigned -Psentry
7575
}
7676

7777
case "${action}" in

tools/gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
this_dir=${BASH_SOURCE[0]%/*}
5+
. "${this_dir}"/lib/ensure-coreutils.sh
6+
root_dir=$(readlink -f "${this_dir}"/..)
7+
8+
exec "${root_dir}"/android/gradlew -p "${root_dir}"/android "$@"

tools/run-android

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cd "${ROOT_DIR}"
1515
# These steps are based on observing `react-native run-android`
1616
# with a command `strace -eexecve -f react-native run-android`.
1717

18-
run_visibly android/gradlew -p android -q :app:installDebug "$@"
18+
run_visibly tools/gradle -q :app:installDebug "$@"
1919

2020
devices=(
2121
$(run_visibly adb devices | perl -0ne 'print "$_\n" for (/^(\S+) \s+ device$/gmx)')

tools/test

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,15 @@ run_native_android() {
145145
files_check android/ \
146146
|| return 0
147147

148-
(
149-
cd android
150-
151-
./gradlew -q :app:assembleDebug :app:assembleDebugUnitTest \
152-
:app:bundleDebug || exit
153-
154-
# The `-q` suppresses noise from warnings about obsolete build config
155-
# in our dependencies from the React Native ecosystem.
156-
# But it also suppresses the names of tests that failed.
157-
# So on failure, rerun without it.
158-
./gradlew -q :app:testDebugUnitTest \
159-
|| ./gradlew :app:testDebugUnitTest || exit
160-
)
148+
tools/gradle -q :app:assembleDebug :app:assembleDebugUnitTest \
149+
:app:bundleDebug || return
150+
151+
# The `-q` suppresses noise from warnings about obsolete build config
152+
# in our dependencies from the React Native ecosystem.
153+
# But it also suppresses the names of tests that failed.
154+
# So on failure, rerun without it.
155+
tools/gradle -q :app:testDebugUnitTest \
156+
|| tools/gradle :app:testDebugUnitTest
161157
}
162158

163159
run_native_ios() {

0 commit comments

Comments
 (0)