-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathandroid_build.yml
More file actions
100 lines (88 loc) · 4.2 KB
/
android_build.yml
File metadata and controls
100 lines (88 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
description: Builds the Android app at the given path with the given build types. This should be run only after installing dependencies.
parameters:
project_path:
description: The path to the root of the Android project you want to build, relative to the root of the repository.
type: string
default: "./android"
build_type:
description: The build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app.
type: string
default: "debug"
test_build_type:
description: The test build type to build. This is normally either "debug" or "release" but you may have custom build types configured for your app.
type: string
default: "debug"
cache:
description: Save and restore the caches? Defaults to true
type: boolean
default: true
assemble_android_test:
description: Configure the android tests to run. Defaults to assembleAndroidTest but you might want to set to app:assembleAndroidTest if that works for your project
type: string
default: assembleAndroidTest
steps:
- when:
condition: <<parameters.cache>>
steps:
- run:
name: Create cache checksum files
command: |
mkdir -p ~/.tmp/checksumfiles
find . -type f -name 'build.gradle' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/build.gradle
find . -type f -name 'settings.gradle' -not -path "*node_modules*" -exec cat {} + >> ~/.tmp/checksumfiles/settings.gradle
- restore_cache:
keys:
- gradle-wrapper-{{ arch }}-{{ checksum "<<parameters.project_path>>/gradle/wrapper/gradle-wrapper.properties" }}-{{ .Environment.CACHE_VERSION }}
- restore_cache:
keys:
- gradle-home-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/build.gradle" }}-{{ checksum "~/.tmp/checksumfiles/settings.gradle" }}-{{ .Environment.CACHE_VERSION }}
- restore_cache:
name: Restoring Gradle Build caches
keys:
- gradle-build-cache-{{ .Revision }}
- run:
name: Dispersing Gradle Build caches for restoring
command: |
[ -d ~/gradle-build-caches ] &&
[ -n "$(ls -A ~/gradle-build-caches)" ] &&
rm -rf ~/.gradle/caches/build-cache-* &&
mkdir -p ~/.gradle/caches/ &&
mv ~/gradle-build-caches/* ~/.gradle/caches/ || true
# download and cache dependencies and Gradle
- run:
name: Downloading Gradle Dependencies
command: "cd <<parameters.project_path>> && chmod +x gradlew && ./gradlew --max-workers 2 downloadDependencies"
- when:
condition: <<parameters.cache>>
steps:
- save_cache:
name: Saving Gradle wrapper cache
paths:
- ~/.gradle/wrapper/
key: gradle-wrapper-{{ arch }}-{{ checksum "<<parameters.project_path>>/gradle/wrapper/gradle-wrapper.properties" }}-{{ .Environment.CACHE_VERSION }}
- save_cache:
name: Saving Gradle home cache
paths:
- ~/.gradle/caches/
key: gradle-home-cache-{{ arch }}-{{ checksum "~/.tmp/checksumfiles/build.gradle" }}-{{ checksum "~/.tmp/checksumfiles/settings.gradle" }}-{{ .Environment.CACHE_VERSION }}
- run:
name: Build Android APK
command: "cd <<parameters.project_path>> && chmod +x gradlew && ./gradlew --build-cache --max-workers 2 --continue assemble<<parameters.build_type>> <<parameters.assemble_android_test>> -DtestBuildType=<<parameters.test_build_type>> --stacktrace"
- when:
condition: <<parameters.cache>>
steps:
- run:
name: Collecting Gradle Build caches for saving
command: |
mkdir -p ~/gradle-build-caches
[ -d ~/.gradle/caches ] &&
[ -n "$(ls -Ad ~/.gradle/caches/build-cache-* 2>/dev/null)" ] &&
rm -rf ~/gradle-build-caches/* &&
mv ~/.gradle/caches/build-cache-* ~/gradle-build-caches || true
when: always
- save_cache:
name: Saving Gradle Build caches
paths:
- ~/gradle-build-caches
key: gradle-build-cache-{{ .Revision }}
when: always