@invarn/cibuild 1.3.16 → 1.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) hide show
  1. package/dist/cli.cjs +1 -1
  2. package/dist/src/cli.d.ts +3 -0
  3. package/dist/src/cli.d.ts.map +1 -0
  4. package/dist/src/cli.js +987 -0
  5. package/dist/src/commands/android-scanner.d.ts +32 -0
  6. package/dist/src/commands/android-scanner.d.ts.map +1 -0
  7. package/dist/src/commands/android-scanner.js +667 -0
  8. package/dist/src/commands/build.d.ts +5 -0
  9. package/dist/src/commands/build.d.ts.map +1 -0
  10. package/dist/src/commands/build.js +1096 -0
  11. package/dist/src/commands/edit.d.ts +3 -0
  12. package/dist/src/commands/edit.d.ts.map +1 -0
  13. package/dist/src/commands/edit.js +651 -0
  14. package/dist/src/commands/file-secret-collector.d.ts +37 -0
  15. package/dist/src/commands/file-secret-collector.d.ts.map +1 -0
  16. package/dist/src/commands/file-secret-collector.js +199 -0
  17. package/dist/src/commands/github-workflow.d.ts +5 -0
  18. package/dist/src/commands/github-workflow.d.ts.map +1 -0
  19. package/dist/src/commands/github-workflow.js +45 -0
  20. package/dist/src/commands/ios-scanner.d.ts +27 -0
  21. package/dist/src/commands/ios-scanner.d.ts.map +1 -0
  22. package/dist/src/commands/ios-scanner.js +337 -0
  23. package/dist/src/commands/reset.d.ts +7 -0
  24. package/dist/src/commands/reset.d.ts.map +1 -0
  25. package/dist/src/commands/reset.js +81 -0
  26. package/dist/src/commands/secrets-sync-workflow.d.ts +15 -0
  27. package/dist/src/commands/secrets-sync-workflow.d.ts.map +1 -0
  28. package/dist/src/commands/secrets-sync-workflow.js +255 -0
  29. package/dist/src/commands/secrets-upload.d.ts +21 -0
  30. package/dist/src/commands/secrets-upload.d.ts.map +1 -0
  31. package/dist/src/commands/secrets-upload.js +177 -0
  32. package/dist/src/commands/secrets-upload.test.d.ts +5 -0
  33. package/dist/src/commands/secrets-upload.test.d.ts.map +1 -0
  34. package/dist/src/commands/secrets-upload.test.js +60 -0
  35. package/dist/src/config.d.ts +3 -0
  36. package/dist/src/config.d.ts.map +1 -0
  37. package/dist/src/config.js +47 -0
  38. package/dist/src/envman/cli.d.ts +21 -0
  39. package/dist/src/envman/cli.d.ts.map +1 -0
  40. package/dist/src/envman/cli.js +240 -0
  41. package/dist/src/envman/envman.d.ts +83 -0
  42. package/dist/src/envman/envman.d.ts.map +1 -0
  43. package/dist/src/envman/envman.js +361 -0
  44. package/dist/src/envman/envman.test.d.ts +5 -0
  45. package/dist/src/envman/envman.test.d.ts.map +1 -0
  46. package/dist/src/envman/envman.test.js +236 -0
  47. package/dist/src/envman/index.d.ts +23 -0
  48. package/dist/src/envman/index.d.ts.map +1 -0
  49. package/dist/src/envman/index.js +23 -0
  50. package/dist/src/envman/types.d.ts +55 -0
  51. package/dist/src/envman/types.d.ts.map +1 -0
  52. package/dist/src/envman/types.js +12 -0
  53. package/dist/src/lib.d.ts +27 -0
  54. package/dist/src/lib.d.ts.map +1 -0
  55. package/dist/src/lib.js +32 -0
  56. package/dist/src/pipeline.d.ts +3 -0
  57. package/dist/src/pipeline.d.ts.map +1 -0
  58. package/dist/src/pipeline.js +57 -0
  59. package/dist/src/runner.d.ts +17 -0
  60. package/dist/src/runner.d.ts.map +1 -0
  61. package/dist/src/runner.js +234 -0
  62. package/dist/src/types.d.ts +58 -0
  63. package/dist/src/types.d.ts.map +1 -0
  64. package/dist/src/types.js +2 -0
  65. package/dist/src/yaml/bitrise-compat.d.ts +65 -0
  66. package/dist/src/yaml/bitrise-compat.d.ts.map +1 -0
  67. package/dist/src/yaml/bitrise-compat.js +206 -0
  68. package/dist/src/yaml/bitrise-compat.test.d.ts +5 -0
  69. package/dist/src/yaml/bitrise-compat.test.d.ts.map +1 -0
  70. package/dist/src/yaml/bitrise-compat.test.js +347 -0
  71. package/dist/src/yaml/converter.d.ts +33 -0
  72. package/dist/src/yaml/converter.d.ts.map +1 -0
  73. package/dist/src/yaml/converter.js +222 -0
  74. package/dist/src/yaml/converter.test.d.ts +5 -0
  75. package/dist/src/yaml/converter.test.d.ts.map +1 -0
  76. package/dist/src/yaml/converter.test.js +348 -0
  77. package/dist/src/yaml/e2e.test.d.ts +6 -0
  78. package/dist/src/yaml/e2e.test.d.ts.map +1 -0
  79. package/dist/src/yaml/e2e.test.js +446 -0
  80. package/dist/src/yaml/env-resolver.d.ts +120 -0
  81. package/dist/src/yaml/env-resolver.d.ts.map +1 -0
  82. package/dist/src/yaml/env-resolver.js +405 -0
  83. package/dist/src/yaml/env-resolver.test.d.ts +5 -0
  84. package/dist/src/yaml/env-resolver.test.d.ts.map +1 -0
  85. package/dist/src/yaml/env-resolver.test.js +502 -0
  86. package/dist/src/yaml/interactive-prompts.d.ts +71 -0
  87. package/dist/src/yaml/interactive-prompts.d.ts.map +1 -0
  88. package/dist/src/yaml/interactive-prompts.js +258 -0
  89. package/dist/src/yaml/missing-env-handler.d.ts +45 -0
  90. package/dist/src/yaml/missing-env-handler.d.ts.map +1 -0
  91. package/dist/src/yaml/missing-env-handler.js +64 -0
  92. package/dist/src/yaml/parser.d.ts +33 -0
  93. package/dist/src/yaml/parser.d.ts.map +1 -0
  94. package/dist/src/yaml/parser.js +145 -0
  95. package/dist/src/yaml/pipeline-with-secrets.d.ts +25 -0
  96. package/dist/src/yaml/pipeline-with-secrets.d.ts.map +1 -0
  97. package/dist/src/yaml/pipeline-with-secrets.js +76 -0
  98. package/dist/src/yaml/platform-detector.d.ts +83 -0
  99. package/dist/src/yaml/platform-detector.d.ts.map +1 -0
  100. package/dist/src/yaml/platform-detector.js +188 -0
  101. package/dist/src/yaml/platform-detector.test.d.ts +5 -0
  102. package/dist/src/yaml/platform-detector.test.d.ts.map +1 -0
  103. package/dist/src/yaml/platform-detector.test.js +414 -0
  104. package/dist/src/yaml/preflight-validation.d.ts +40 -0
  105. package/dist/src/yaml/preflight-validation.d.ts.map +1 -0
  106. package/dist/src/yaml/preflight-validation.js +152 -0
  107. package/dist/src/yaml/secrets-manager.d.ts +77 -0
  108. package/dist/src/yaml/secrets-manager.d.ts.map +1 -0
  109. package/dist/src/yaml/secrets-manager.js +219 -0
  110. package/dist/src/yaml/step-validator.d.ts +54 -0
  111. package/dist/src/yaml/step-validator.d.ts.map +1 -0
  112. package/dist/src/yaml/step-validator.js +403 -0
  113. package/dist/src/yaml/steps/android-sign.d.ts +35 -0
  114. package/dist/src/yaml/steps/android-sign.d.ts.map +1 -0
  115. package/dist/src/yaml/steps/android-sign.js +147 -0
  116. package/dist/src/yaml/steps/android-version.d.ts +26 -0
  117. package/dist/src/yaml/steps/android-version.d.ts.map +1 -0
  118. package/dist/src/yaml/steps/android-version.js +128 -0
  119. package/dist/src/yaml/steps/android-version.test.d.ts +5 -0
  120. package/dist/src/yaml/steps/android-version.test.d.ts.map +1 -0
  121. package/dist/src/yaml/steps/android-version.test.js +196 -0
  122. package/dist/src/yaml/steps/android.d.ts +95 -0
  123. package/dist/src/yaml/steps/android.d.ts.map +1 -0
  124. package/dist/src/yaml/steps/android.js +916 -0
  125. package/dist/src/yaml/steps/app-store-deploy.d.ts +48 -0
  126. package/dist/src/yaml/steps/app-store-deploy.d.ts.map +1 -0
  127. package/dist/src/yaml/steps/app-store-deploy.js +162 -0
  128. package/dist/src/yaml/steps/base.d.ts +238 -0
  129. package/dist/src/yaml/steps/base.d.ts.map +1 -0
  130. package/dist/src/yaml/steps/base.js +345 -0
  131. package/dist/src/yaml/steps/bitrise-android-tools.d.ts +26 -0
  132. package/dist/src/yaml/steps/bitrise-android-tools.d.ts.map +1 -0
  133. package/dist/src/yaml/steps/bitrise-android-tools.js +198 -0
  134. package/dist/src/yaml/steps/bitrise-android-tools.test.d.ts +5 -0
  135. package/dist/src/yaml/steps/bitrise-android-tools.test.d.ts.map +1 -0
  136. package/dist/src/yaml/steps/bitrise-android-tools.test.js +280 -0
  137. package/dist/src/yaml/steps/bitrise-apk-info.d.ts +22 -0
  138. package/dist/src/yaml/steps/bitrise-apk-info.d.ts.map +1 -0
  139. package/dist/src/yaml/steps/bitrise-apk-info.js +144 -0
  140. package/dist/src/yaml/steps/bitrise-apk-info.test.d.ts +5 -0
  141. package/dist/src/yaml/steps/bitrise-apk-info.test.d.ts.map +1 -0
  142. package/dist/src/yaml/steps/bitrise-apk-info.test.js +331 -0
  143. package/dist/src/yaml/steps/bitrise-slack.d.ts +49 -0
  144. package/dist/src/yaml/steps/bitrise-slack.d.ts.map +1 -0
  145. package/dist/src/yaml/steps/bitrise-slack.js +280 -0
  146. package/dist/src/yaml/steps/bitrise-slack.test.d.ts +5 -0
  147. package/dist/src/yaml/steps/bitrise-slack.test.d.ts.map +1 -0
  148. package/dist/src/yaml/steps/bitrise-slack.test.js +484 -0
  149. package/dist/src/yaml/steps/bitrise-ssh.d.ts +27 -0
  150. package/dist/src/yaml/steps/bitrise-ssh.d.ts.map +1 -0
  151. package/dist/src/yaml/steps/bitrise-ssh.js +134 -0
  152. package/dist/src/yaml/steps/bitrise-ssh.test.d.ts +5 -0
  153. package/dist/src/yaml/steps/bitrise-ssh.test.d.ts.map +1 -0
  154. package/dist/src/yaml/steps/bitrise-ssh.test.js +205 -0
  155. package/dist/src/yaml/steps/cache.d.ts +52 -0
  156. package/dist/src/yaml/steps/cache.d.ts.map +1 -0
  157. package/dist/src/yaml/steps/cache.js +352 -0
  158. package/dist/src/yaml/steps/fastlane.d.ts +27 -0
  159. package/dist/src/yaml/steps/fastlane.d.ts.map +1 -0
  160. package/dist/src/yaml/steps/fastlane.js +79 -0
  161. package/dist/src/yaml/steps/file.d.ts +27 -0
  162. package/dist/src/yaml/steps/file.d.ts.map +1 -0
  163. package/dist/src/yaml/steps/file.js +35 -0
  164. package/dist/src/yaml/steps/flutter.d.ts +63 -0
  165. package/dist/src/yaml/steps/flutter.d.ts.map +1 -0
  166. package/dist/src/yaml/steps/flutter.js +215 -0
  167. package/dist/src/yaml/steps/git-clone.d.ts +26 -0
  168. package/dist/src/yaml/steps/git-clone.d.ts.map +1 -0
  169. package/dist/src/yaml/steps/git-clone.js +111 -0
  170. package/dist/src/yaml/steps/google-play-deploy.d.ts +37 -0
  171. package/dist/src/yaml/steps/google-play-deploy.d.ts.map +1 -0
  172. package/dist/src/yaml/steps/google-play-deploy.js +193 -0
  173. package/dist/src/yaml/steps/google-play-deploy.test.d.ts +5 -0
  174. package/dist/src/yaml/steps/google-play-deploy.test.d.ts.map +1 -0
  175. package/dist/src/yaml/steps/google-play-deploy.test.js +310 -0
  176. package/dist/src/yaml/steps/index.d.ts +10 -0
  177. package/dist/src/yaml/steps/index.d.ts.map +1 -0
  178. package/dist/src/yaml/steps/index.js +1361 -0
  179. package/dist/src/yaml/steps/ios-deps.d.ts +43 -0
  180. package/dist/src/yaml/steps/ios-deps.d.ts.map +1 -0
  181. package/dist/src/yaml/steps/ios-deps.js +141 -0
  182. package/dist/src/yaml/steps/ios-deps.test.d.ts +5 -0
  183. package/dist/src/yaml/steps/ios-deps.test.d.ts.map +1 -0
  184. package/dist/src/yaml/steps/ios-deps.test.js +90 -0
  185. package/dist/src/yaml/steps/ios-signing.d.ts +31 -0
  186. package/dist/src/yaml/steps/ios-signing.d.ts.map +1 -0
  187. package/dist/src/yaml/steps/ios-signing.js +144 -0
  188. package/dist/src/yaml/steps/ios-version.d.ts +47 -0
  189. package/dist/src/yaml/steps/ios-version.d.ts.map +1 -0
  190. package/dist/src/yaml/steps/ios-version.js +151 -0
  191. package/dist/src/yaml/steps/linting.d.ts +47 -0
  192. package/dist/src/yaml/steps/linting.d.ts.map +1 -0
  193. package/dist/src/yaml/steps/linting.js +148 -0
  194. package/dist/src/yaml/steps/phase2.test.d.ts +6 -0
  195. package/dist/src/yaml/steps/phase2.test.d.ts.map +1 -0
  196. package/dist/src/yaml/steps/phase2.test.js +197 -0
  197. package/dist/src/yaml/steps/phase3.test.d.ts +5 -0
  198. package/dist/src/yaml/steps/phase3.test.d.ts.map +1 -0
  199. package/dist/src/yaml/steps/phase3.test.js +144 -0
  200. package/dist/src/yaml/steps/phase4.test.d.ts +5 -0
  201. package/dist/src/yaml/steps/phase4.test.d.ts.map +1 -0
  202. package/dist/src/yaml/steps/phase4.test.js +166 -0
  203. package/dist/src/yaml/steps/phase5.test.d.ts +6 -0
  204. package/dist/src/yaml/steps/phase5.test.d.ts.map +1 -0
  205. package/dist/src/yaml/steps/phase5.test.js +263 -0
  206. package/dist/src/yaml/steps/registry.d.ts +88 -0
  207. package/dist/src/yaml/steps/registry.d.ts.map +1 -0
  208. package/dist/src/yaml/steps/registry.js +125 -0
  209. package/dist/src/yaml/steps/registry.test.d.ts +5 -0
  210. package/dist/src/yaml/steps/registry.test.d.ts.map +1 -0
  211. package/dist/src/yaml/steps/registry.test.js +235 -0
  212. package/dist/src/yaml/steps/release.d.ts +50 -0
  213. package/dist/src/yaml/steps/release.d.ts.map +1 -0
  214. package/dist/src/yaml/steps/release.js +154 -0
  215. package/dist/src/yaml/steps/script.d.ts +23 -0
  216. package/dist/src/yaml/steps/script.d.ts.map +1 -0
  217. package/dist/src/yaml/steps/script.js +63 -0
  218. package/dist/src/yaml/steps/spec-validation.test.d.ts +6 -0
  219. package/dist/src/yaml/steps/spec-validation.test.d.ts.map +1 -0
  220. package/dist/src/yaml/steps/spec-validation.test.js +130 -0
  221. package/dist/src/yaml/steps/steps.test.d.ts +6 -0
  222. package/dist/src/yaml/steps/steps.test.d.ts.map +1 -0
  223. package/dist/src/yaml/steps/steps.test.js +505 -0
  224. package/dist/src/yaml/steps/test-config.d.ts +3 -0
  225. package/dist/src/yaml/steps/test-config.d.ts.map +1 -0
  226. package/dist/src/yaml/steps/test-config.js +17 -0
  227. package/dist/src/yaml/steps/xcode-new.test.d.ts +5 -0
  228. package/dist/src/yaml/steps/xcode-new.test.d.ts.map +1 -0
  229. package/dist/src/yaml/steps/xcode-new.test.js +211 -0
  230. package/dist/src/yaml/steps/xcode.d.ts +222 -0
  231. package/dist/src/yaml/steps/xcode.d.ts.map +1 -0
  232. package/dist/src/yaml/steps/xcode.js +999 -0
  233. package/dist/src/yaml/types.d.ts +68 -0
  234. package/dist/src/yaml/types.d.ts.map +1 -0
  235. package/dist/src/yaml/types.js +5 -0
  236. package/dist/src/yaml/validation-types.d.ts +96 -0
  237. package/dist/src/yaml/validation-types.d.ts.map +1 -0
  238. package/dist/src/yaml/validation-types.js +8 -0
  239. package/dist/src/yaml/yaml-updater.d.ts +24 -0
  240. package/dist/src/yaml/yaml-updater.d.ts.map +1 -0
  241. package/dist/src/yaml/yaml-updater.js +128 -0
  242. package/package.json +16 -4
@@ -0,0 +1,916 @@
1
+ /**
2
+ * Android step implementations (set-java-version, gradle-build, android-lint, android-unit-test)
3
+ */
4
+ import { BaseStepExecutor } from './base.js';
5
+ /**
6
+ * Set Java version step executor
7
+ * Sets the Java version to use for Android builds
8
+ */
9
+ export class SetJavaVersionStepExecutor extends BaseStepExecutor {
10
+ getValidationRequirements(inputs, _env, _config) {
11
+ const javaVersion = this.getInput(inputs, 'java_version', '17');
12
+ return [
13
+ {
14
+ category: 'command',
15
+ name: `java-${javaVersion}`,
16
+ description: `Java ${javaVersion} JDK`,
17
+ timing: 'pre-execution',
18
+ severity: 'info', // Info because we check multiple locations including Homebrew
19
+ hint: process.platform === 'darwin'
20
+ ? `Install: brew install openjdk@${javaVersion}`
21
+ : `Install: sudo apt install openjdk-${javaVersion}-jdk`,
22
+ check: async () => this.checkJavaVersionWithHomebrew(String(javaVersion)),
23
+ },
24
+ ];
25
+ }
26
+ /**
27
+ * Check Java version including Homebrew installations
28
+ * Matches the logic in execute() method
29
+ */
30
+ async checkJavaVersionWithHomebrew(version) {
31
+ const { existsSync } = await import('node:fs');
32
+ const { execSync } = await import('node:child_process');
33
+ // Check Homebrew paths first (same order as execute())
34
+ const homebrewPaths = [
35
+ `/opt/homebrew/opt/openjdk@${version}`, // Apple Silicon
36
+ `/usr/local/opt/openjdk@${version}`, // Intel Mac
37
+ ];
38
+ for (const path of homebrewPaths) {
39
+ if (existsSync(path)) {
40
+ return {
41
+ passed: true,
42
+ message: `Java ${version} found at: ${path}`,
43
+ };
44
+ }
45
+ }
46
+ // Check Android Studio JBR
47
+ if (process.platform === 'darwin') {
48
+ const jbrPath = '/Applications/Android Studio.app/Contents/jbr/Contents/Home';
49
+ if (existsSync(jbrPath)) {
50
+ try {
51
+ const { readFileSync } = await import('node:fs');
52
+ const releaseContent = readFileSync(`${jbrPath}/release`, 'utf-8');
53
+ const jbrVersionMatch = /JAVA_VERSION="(\d+)/.exec(releaseContent);
54
+ if (jbrVersionMatch && jbrVersionMatch[1] === String(version)) {
55
+ return { passed: true, message: `Java ${version} found at: ${jbrPath} (Android Studio JBR)` };
56
+ }
57
+ }
58
+ catch {
59
+ // Ignore — release file unreadable
60
+ }
61
+ }
62
+ }
63
+ // Try java_home utility on macOS
64
+ if (process.platform === 'darwin') {
65
+ try {
66
+ execSync(`/usr/libexec/java_home -v "${version}"`, { stdio: 'pipe' });
67
+ return { passed: true, message: `Java ${version} is available` };
68
+ }
69
+ catch {
70
+ // Try with pattern
71
+ try {
72
+ execSync(`/usr/libexec/java_home -v "${version}.*"`, { stdio: 'pipe' });
73
+ return { passed: true, message: `Java ${version} is available` };
74
+ }
75
+ catch {
76
+ // Continue to Linux paths
77
+ }
78
+ }
79
+ }
80
+ // Check Linux paths
81
+ const linuxPaths = [
82
+ `/usr/lib/jvm/java-${version}-openjdk-amd64`,
83
+ `/usr/lib/jvm/java-${version}-openjdk`,
84
+ `/usr/lib/jvm/temurin-${version}-jdk-amd64`,
85
+ ];
86
+ for (const path of linuxPaths) {
87
+ if (existsSync(path)) {
88
+ return {
89
+ passed: true,
90
+ message: `Java ${version} found at: ${path}`,
91
+ };
92
+ }
93
+ }
94
+ return {
95
+ passed: false,
96
+ message: `Java ${version} not found`,
97
+ details: process.platform === 'darwin'
98
+ ? `Install: brew install openjdk@${version}`
99
+ : `Install: sudo apt install openjdk-${version}-jdk`,
100
+ };
101
+ }
102
+ getOutputs() {
103
+ return [
104
+ {
105
+ name: 'JAVA_HOME',
106
+ type: 'environment',
107
+ description: 'Path to Java installation',
108
+ },
109
+ ];
110
+ }
111
+ async execute(inputs, env, config) {
112
+ const stepName = 'set-java-version';
113
+ // Get Java version - defaults to 17
114
+ const javaVersion = this.getInput(inputs, 'java_version', '17');
115
+ const commands = [];
116
+ commands.push('# Set Java Version');
117
+ commands.push(`echo "Setting Java version to: ${javaVersion}"`);
118
+ // Set JAVA_HOME based on version
119
+ commands.push('');
120
+ commands.push('# Set JAVA_HOME');
121
+ // Common Java installation paths
122
+ commands.push(`JAVA_VERSION="${javaVersion}"`);
123
+ commands.push('');
124
+ commands.push('# Try to locate Java installation');
125
+ commands.push('JAVA_HOME=""');
126
+ commands.push('');
127
+ commands.push('# 1. Homebrew Apple Silicon');
128
+ commands.push('if [ -d "/opt/homebrew/opt/openjdk@${JAVA_VERSION}" ]; then');
129
+ commands.push(' JAVA_HOME="/opt/homebrew/opt/openjdk@${JAVA_VERSION}"');
130
+ commands.push(' echo "Found Java at: $JAVA_HOME (Homebrew Apple Silicon)"');
131
+ commands.push('fi');
132
+ commands.push('');
133
+ commands.push('# 2. Homebrew Intel');
134
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -d "/usr/local/opt/openjdk@${JAVA_VERSION}" ]; then');
135
+ commands.push(' JAVA_HOME="/usr/local/opt/openjdk@${JAVA_VERSION}"');
136
+ commands.push(' echo "Found Java at: $JAVA_HOME (Homebrew Intel)"');
137
+ commands.push('fi');
138
+ commands.push('');
139
+ commands.push('# 3. Android Studio JBR');
140
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -d "/Applications/Android Studio.app/Contents/jbr/Contents/Home" ]; then');
141
+ commands.push(' JBR_PATH="/Applications/Android Studio.app/Contents/jbr/Contents/Home"');
142
+ commands.push(' JBR_MAJOR=$(grep "^JAVA_VERSION=" "$JBR_PATH/release" 2>/dev/null | grep -oE \'"[0-9]+\' | tr -d \'"\' || echo "")');
143
+ commands.push(' if [ "$JBR_MAJOR" = "$JAVA_VERSION" ]; then');
144
+ commands.push(' JAVA_HOME="$JBR_PATH"');
145
+ commands.push(' echo "Found Java at: $JAVA_HOME (Android Studio JBR)"');
146
+ commands.push(' fi');
147
+ commands.push('fi');
148
+ commands.push('');
149
+ commands.push('# 4. macOS java_home utility');
150
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then');
151
+ commands.push(' JAVA_HOME=$(/usr/libexec/java_home -v "$JAVA_VERSION" 2>/dev/null || true)');
152
+ commands.push(' if [ -z "$JAVA_HOME" ]; then');
153
+ commands.push(' JAVA_HOME=$(/usr/libexec/java_home -v "${JAVA_VERSION}.*" 2>/dev/null || true)');
154
+ commands.push(' fi');
155
+ commands.push(' if [ -n "$JAVA_HOME" ]; then');
156
+ commands.push(' echo "Found Java at: $JAVA_HOME (java_home)"');
157
+ commands.push(' fi');
158
+ commands.push('fi');
159
+ commands.push('');
160
+ commands.push('# 5. GitHub Actions runner (JAVA_HOME_<ver>_X64 env var)');
161
+ commands.push('JAVA_HOME_VAR="JAVA_HOME_${JAVA_VERSION}_X64"');
162
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -n "${!JAVA_HOME_VAR:-}" ]; then');
163
+ commands.push(' JAVA_HOME="${!JAVA_HOME_VAR}"');
164
+ commands.push(' echo "Found Java at: $JAVA_HOME (GitHub Actions)"');
165
+ commands.push('fi');
166
+ commands.push('');
167
+ commands.push('# 6. Linux paths');
168
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -d "/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-amd64" ]; then');
169
+ commands.push(' JAVA_HOME="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-amd64"');
170
+ commands.push(' echo "Found Java at: $JAVA_HOME (Temurin)"');
171
+ commands.push('fi');
172
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -d "/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64" ]; then');
173
+ commands.push(' JAVA_HOME="/usr/lib/jvm/java-${JAVA_VERSION}-openjdk-amd64"');
174
+ commands.push(' echo "Found Java at: $JAVA_HOME (Linux)"');
175
+ commands.push('fi');
176
+ commands.push('if [ -z "$JAVA_HOME" ] && [ -d "/usr/lib/jvm/java-${JAVA_VERSION}-openjdk" ]; then');
177
+ commands.push(' JAVA_HOME="/usr/lib/jvm/java-${JAVA_VERSION}-openjdk"');
178
+ commands.push(' echo "Found Java at: $JAVA_HOME (Linux alt)"');
179
+ commands.push('fi');
180
+ commands.push('');
181
+ commands.push('# Validate JAVA_HOME was found');
182
+ commands.push('if [ -z "$JAVA_HOME" ] || [ ! -d "$JAVA_HOME" ]; then');
183
+ commands.push(' echo "⚠️ Java $JAVA_VERSION not found"');
184
+ commands.push(' echo ""');
185
+ commands.push(' echo "Available versions:"');
186
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
187
+ commands.push(' /usr/libexec/java_home -V 2>&1 | grep -E "^[[:space:]]+[0-9]" || echo " No Java installations found via java_home"');
188
+ commands.push(' fi');
189
+ commands.push(' if [ -d "/Applications/Android Studio.app/Contents/jbr/Contents/Home" ]; then');
190
+ commands.push(' JBR_VER=$(grep "^JAVA_VERSION=" "/Applications/Android Studio.app/Contents/jbr/Contents/Home/release" 2>/dev/null | grep -oE \'"[0-9.]+\' | tr -d \'"\' || echo "unknown")');
191
+ commands.push(' echo " Android Studio JBR: $JBR_VER (/Applications/Android Studio.app/Contents/jbr/Contents/Home)"');
192
+ commands.push(' fi');
193
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
194
+ commands.push(' echo ""');
195
+ commands.push(' echo "Install Java $JAVA_VERSION:"');
196
+ commands.push(' echo " brew install openjdk@$JAVA_VERSION"');
197
+ commands.push(' else');
198
+ commands.push(' echo "Install Java $JAVA_VERSION (Ubuntu/Debian):"');
199
+ commands.push(' echo " sudo apt-get install openjdk-${JAVA_VERSION}-jdk"');
200
+ commands.push(' fi');
201
+ commands.push(' exit 1');
202
+ commands.push('fi');
203
+ commands.push('');
204
+ commands.push('export JAVA_HOME');
205
+ commands.push('');
206
+ commands.push('# Update PATH');
207
+ commands.push('export PATH="$JAVA_HOME/bin:$PATH"');
208
+ commands.push('');
209
+ commands.push('# Verify Java version');
210
+ commands.push('echo "JAVA_HOME: $JAVA_HOME"');
211
+ commands.push('java -version');
212
+ commands.push('');
213
+ commands.push('# Persist JAVA_HOME to envman for subsequent steps');
214
+ commands.push('envman add --key JAVA_HOME --value "$JAVA_HOME"');
215
+ const script = this.createBashScriptFromCommands(commands, stepName);
216
+ return this.createScriptStep(script, stepName);
217
+ }
218
+ }
219
+ /**
220
+ * Gradle build step executor
221
+ * Builds Android projects using Gradle
222
+ */
223
+ export class GradleBuildStepExecutor extends BaseStepExecutor {
224
+ getOutputs() {
225
+ return [
226
+ {
227
+ name: 'CIBUILD_APK_PATH',
228
+ type: 'environment',
229
+ description: 'Path to the built APK file',
230
+ },
231
+ {
232
+ name: 'CIBUILD_AAB_PATH',
233
+ type: 'environment',
234
+ description: 'Path to the built AAB file',
235
+ },
236
+ ];
237
+ }
238
+ getValidationRequirements(_inputs, env, _config) {
239
+ return [
240
+ this.requireEnvVar('JAVA_HOME', 'Java installation directory', env, 'Add a set-java-version step before gradle-build, or set JAVA_HOME env var'),
241
+ this.runtimeRequirement('gradlew', 'Gradle wrapper (./gradlew) or gradle command', 'file', 'git-clone'),
242
+ ];
243
+ }
244
+ async execute(inputs, env, config) {
245
+ const stepName = 'gradle-build';
246
+ // Get project location from YAML input (if explicitly specified)
247
+ const explicitLocation = this.getInput(inputs, 'project_location', '');
248
+ // Handle both gradle-build and android-build (Bitrise) inputs
249
+ // Bitrise android-build uses: variant (debug/release), module (app)
250
+ // Our gradle-build uses: build_type (Debug/Release)
251
+ const variant = this.getInput(inputs, 'variant', '');
252
+ const module = this.getInput(inputs, 'module', '');
253
+ const buildType = this.getInput(inputs, 'build_type', '');
254
+ // Determine build type from variant or build_type
255
+ let finalBuildType = 'Release';
256
+ if (variant && variant.length > 0) {
257
+ // Bitrise android-build: use variant (e.g., "debug" -> "Debug", "release" -> "Release")
258
+ finalBuildType = variant.charAt(0).toUpperCase() + variant.slice(1).toLowerCase();
259
+ }
260
+ else if (buildType && buildType.length > 0) {
261
+ // gradle-build: use build_type
262
+ finalBuildType = buildType;
263
+ }
264
+ // Build gradle task name
265
+ let defaultTask;
266
+ if (module && module.length > 0 && variant && variant.length > 0) {
267
+ // Bitrise android-build: :module:assembleVariant (e.g., :app:assembleDebug)
268
+ const variantCapitalized = variant.charAt(0).toUpperCase() + variant.slice(1).toLowerCase();
269
+ defaultTask = `:${module}:assemble${variantCapitalized}`;
270
+ }
271
+ else {
272
+ // gradle-build: assembleRelease/assembleDebug
273
+ defaultTask = finalBuildType.toLowerCase() === 'debug' ? 'assembleDebug' : 'assembleRelease';
274
+ }
275
+ const gradleTask = this.getInput(inputs, 'gradle_task', defaultTask);
276
+ // Get gradle options - optional
277
+ const gradleOptions = this.getInput(inputs, 'gradle_options', '');
278
+ const commands = [];
279
+ commands.push('# Gradle Build');
280
+ commands.push('');
281
+ // Add JAVA_HOME validation and auto-detection
282
+ commands.push('# Validate and auto-detect JAVA_HOME if needed');
283
+ commands.push('if [ -n "$JAVA_HOME" ] && [ ! -d "$JAVA_HOME" ]; then');
284
+ commands.push(' echo "⚠️ JAVA_HOME is set but points to invalid directory: $JAVA_HOME"');
285
+ commands.push(' ');
286
+ commands.push(' # Extract Java version from invalid path (e.g., "11" from /usr/lib/jvm/java-11-openjdk-amd64)');
287
+ commands.push(' REQUESTED_VERSION=$(echo "$JAVA_HOME" | grep -oE "java-[0-9]+" | grep -oE "[0-9]+" || echo "")');
288
+ commands.push(' if [ -z "$REQUESTED_VERSION" ]; then');
289
+ commands.push(' # Try alternative patterns (e.g., openjdk@17, openjdk-17)');
290
+ commands.push(' REQUESTED_VERSION=$(echo "$JAVA_HOME" | grep -oE "(openjdk[@-])[0-9]+" | grep -oE "[0-9]+" || echo "")');
291
+ commands.push(' fi');
292
+ commands.push(' ');
293
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
294
+ commands.push(' echo "Detected requested Java version: $REQUESTED_VERSION"');
295
+ commands.push(' echo "Attempting to find Java $REQUESTED_VERSION on this system..."');
296
+ commands.push(' else');
297
+ commands.push(' echo "Could not detect Java version from path, will try to find any Java..."');
298
+ commands.push(' fi');
299
+ commands.push(' echo ""');
300
+ commands.push(' ');
301
+ commands.push(' # Try to auto-detect Java for the requested version');
302
+ commands.push(' DETECTED_JAVA_HOME=""');
303
+ commands.push(' ');
304
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
305
+ commands.push(' # Check Homebrew installation paths for specific version (Apple Silicon)');
306
+ commands.push(' if [ -d "/opt/homebrew/opt/openjdk@${REQUESTED_VERSION}" ]; then');
307
+ commands.push(' DETECTED_JAVA_HOME="/opt/homebrew/opt/openjdk@${REQUESTED_VERSION}"');
308
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Homebrew Apple Silicon)"');
309
+ commands.push(' # Check Homebrew installation paths (Intel Mac)');
310
+ commands.push(' elif [ -d "/usr/local/opt/openjdk@${REQUESTED_VERSION}" ]; then');
311
+ commands.push(' DETECTED_JAVA_HOME="/usr/local/opt/openjdk@${REQUESTED_VERSION}"');
312
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Homebrew Intel)"');
313
+ commands.push(' # Check Android Studio JBR');
314
+ commands.push(' elif [ -d "/Applications/Android Studio.app/Contents/jbr/Contents/Home" ]; then');
315
+ commands.push(' JBR_PATH="/Applications/Android Studio.app/Contents/jbr/Contents/Home"');
316
+ commands.push(' JBR_MAJOR=$(grep "^JAVA_VERSION=" "$JBR_PATH/release" 2>/dev/null | grep -oE \'"[0-9]+\' | tr -d \'"\' || echo "")');
317
+ commands.push(' if [ "$JBR_MAJOR" = "$REQUESTED_VERSION" ]; then');
318
+ commands.push(' DETECTED_JAVA_HOME="$JBR_PATH"');
319
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Android Studio JBR)"');
320
+ commands.push(' fi');
321
+ commands.push(' # Try macOS java_home utility for specific version');
322
+ commands.push(' elif [ -x "/usr/libexec/java_home" ]; then');
323
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home -v "${REQUESTED_VERSION}" 2>/dev/null || true)');
324
+ commands.push(' if [ -z "$DETECTED_JAVA_HOME" ]; then');
325
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home -v "${REQUESTED_VERSION}.*" 2>/dev/null || true)');
326
+ commands.push(' fi');
327
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ]; then');
328
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (java_home utility)"');
329
+ commands.push(' fi');
330
+ commands.push(' fi');
331
+ commands.push(' fi');
332
+ commands.push(' ');
333
+ commands.push(' # If specific version not found, try any Java as fallback');
334
+ commands.push(' if [ -z "$DETECTED_JAVA_HOME" ]; then');
335
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
336
+ commands.push(' echo "⚠️ Java $REQUESTED_VERSION not found, checking for other versions..."');
337
+ commands.push(' fi');
338
+ commands.push(' ');
339
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
340
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home 2>/dev/null || true)');
341
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ]; then');
342
+ commands.push(' FALLBACK_VERSION=$("$DETECTED_JAVA_HOME/bin/java" -version 2>&1 | head -n 1 | grep -oE "[0-9]+" | head -n 1)');
343
+ commands.push(' echo "⚠️ Found Java $FALLBACK_VERSION instead of requested version $REQUESTED_VERSION"');
344
+ commands.push(' echo " Location: $DETECTED_JAVA_HOME"');
345
+ commands.push(' echo " ⚠️ WARNING: This may cause build issues if Java $REQUESTED_VERSION is required"');
346
+ commands.push(' fi');
347
+ commands.push(' fi');
348
+ commands.push(' fi');
349
+ commands.push(' ');
350
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ] && [ -d "$DETECTED_JAVA_HOME" ]; then');
351
+ commands.push(' export JAVA_HOME="$DETECTED_JAVA_HOME"');
352
+ commands.push(' echo "✅ Auto-corrected JAVA_HOME to: $JAVA_HOME"');
353
+ commands.push(' echo ""');
354
+ commands.push(' else');
355
+ commands.push(' echo ""');
356
+ commands.push(' echo "❌ Could not auto-detect valid Java installation"');
357
+ commands.push(' echo ""');
358
+ commands.push(' echo "JAVA_HOME is set to: $JAVA_HOME"');
359
+ commands.push(' echo "But this directory does not exist on your system."');
360
+ commands.push(' echo ""');
361
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
362
+ commands.push(' echo "Required Java version: $REQUESTED_VERSION"');
363
+ commands.push(' echo ""');
364
+ commands.push(' fi');
365
+ commands.push(' echo "To fix this issue:"');
366
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
367
+ commands.push(' echo " 1. Check available Java versions:"');
368
+ commands.push(' echo " /usr/libexec/java_home -V"');
369
+ commands.push(' echo ""');
370
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
371
+ commands.push(' echo " 2. Install Java $REQUESTED_VERSION via Homebrew:"');
372
+ commands.push(' echo " brew install openjdk@$REQUESTED_VERSION"');
373
+ commands.push(' else');
374
+ commands.push(' echo " 2. Install Java via Homebrew:"');
375
+ commands.push(' echo " brew install openjdk@17"');
376
+ commands.push(' fi');
377
+ commands.push(' echo ""');
378
+ commands.push(' echo " 3. Update JAVA_HOME in your secrets or add set-java-version step"');
379
+ commands.push(' else');
380
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
381
+ commands.push(' echo " 1. Install Java $REQUESTED_VERSION (Ubuntu/Debian):"');
382
+ commands.push(' echo " sudo apt-get install openjdk-${REQUESTED_VERSION}-jdk"');
383
+ commands.push(' else');
384
+ commands.push(' echo " 1. Install Java (Ubuntu/Debian):"');
385
+ commands.push(' echo " sudo apt-get install openjdk-17-jdk"');
386
+ commands.push(' fi');
387
+ commands.push(' echo ""');
388
+ commands.push(' echo " 2. Update JAVA_HOME in your secrets or add set-java-version step"');
389
+ commands.push(' fi');
390
+ commands.push(' echo ""');
391
+ commands.push(' exit 1');
392
+ commands.push(' fi');
393
+ commands.push('fi');
394
+ commands.push('');
395
+ // Determine project location at runtime: explicit > CIBUILD_SOURCE_DIR > current dir
396
+ if (explicitLocation && explicitLocation !== '.') {
397
+ commands.push(`PROJECT_DIR='${this.escapeBash(explicitLocation)}'`);
398
+ }
399
+ else {
400
+ commands.push('PROJECT_DIR="${CIBUILD_SOURCE_DIR:-.}"');
401
+ }
402
+ commands.push('echo "Building Android project: $PROJECT_DIR"');
403
+ commands.push(`echo "Build type: ${this.escapeBash(finalBuildType)}"`);
404
+ if (module) {
405
+ commands.push(`echo "Module: ${this.escapeBash(module)}"`);
406
+ }
407
+ commands.push(`echo "Gradle task: ${this.escapeBash(gradleTask)}"`);
408
+ // Change to project directory
409
+ commands.push('');
410
+ commands.push('if [ "$PROJECT_DIR" != "." ]; then');
411
+ commands.push(' cd "$PROJECT_DIR"');
412
+ commands.push('fi');
413
+ // Make gradlew executable
414
+ commands.push('');
415
+ commands.push('# Make gradlew executable');
416
+ commands.push('if [ -f "./gradlew" ]; then');
417
+ commands.push(' chmod +x ./gradlew');
418
+ commands.push(' GRADLE_CMD="./gradlew"');
419
+ commands.push('elif command -v gradle &> /dev/null; then');
420
+ commands.push(' GRADLE_CMD="gradle"');
421
+ commands.push('else');
422
+ commands.push(' echo "Error: Neither ./gradlew nor gradle command found"');
423
+ commands.push(' exit 1');
424
+ commands.push('fi');
425
+ // Build gradle command
426
+ commands.push('');
427
+ commands.push('# Timestamp marker — used to collect only artifacts from this build');
428
+ commands.push('touch /tmp/.cibuild-build-marker');
429
+ commands.push('');
430
+ commands.push('# Run Gradle build');
431
+ let gradleCmd = `$GRADLE_CMD ${this.escapeBash(gradleTask)}`;
432
+ if (gradleOptions && gradleOptions.trim() !== '') {
433
+ gradleCmd += ` ${gradleOptions}`;
434
+ }
435
+ commands.push(gradleCmd);
436
+ commands.push('');
437
+ commands.push('# Build completed');
438
+ commands.push('echo "Gradle build completed successfully"');
439
+ commands.push('');
440
+ // Copy artifacts to artifacts directory for deploy step
441
+ commands.push('# Copy build artifacts to artifacts directory');
442
+ commands.push('ARTIFACTS_DIR="${CIBUILD_ARTIFACTS_DIR:-.ci/artifacts}"');
443
+ commands.push('mkdir -p "$ARTIFACTS_DIR"');
444
+ commands.push('');
445
+ commands.push('# Find and copy only APK/AAB files produced by this build (newer than marker)');
446
+ commands.push('echo "Collecting build artifacts..."');
447
+ commands.push('if find . -newer /tmp/.cibuild-build-marker \\( -path "*/build/outputs/apk/*/*.apk" -o -path "*/build/outputs/bundle/*/*.aab" \\) 2>/dev/null | grep -q .; then');
448
+ commands.push(' find . -newer /tmp/.cibuild-build-marker \\( -path "*/build/outputs/apk/*/*.apk" -o -path "*/build/outputs/bundle/*/*.aab" \\) 2>/dev/null | while read -r artifact; do');
449
+ commands.push(' ARTIFACT_NAME=$(basename "$artifact")');
450
+ commands.push(' cp "$artifact" "$ARTIFACTS_DIR/$ARTIFACT_NAME"');
451
+ commands.push(' echo " → Copied: $ARTIFACT_NAME"');
452
+ commands.push(' echo " From: $artifact"');
453
+ commands.push(' echo " To: $ARTIFACTS_DIR/$ARTIFACT_NAME"');
454
+ commands.push(' done');
455
+ commands.push(' echo ""');
456
+ commands.push(' echo "✅ Artifacts copied to: $ARTIFACTS_DIR"');
457
+ commands.push(' ls -lh "$ARTIFACTS_DIR"');
458
+ commands.push('else');
459
+ commands.push(' echo "⚠️ No APK or AAB files found in build/outputs/"');
460
+ commands.push('fi');
461
+ commands.push('rm -f /tmp/.cibuild-build-marker');
462
+ commands.push('');
463
+ commands.push('# Export artifact paths for subsequent steps (e.g. google-play-deploy)');
464
+ commands.push('FIRST_APK=$(find "$ARTIFACTS_DIR" -name "*.apk" -type f | sort | head -n 1)');
465
+ commands.push('FIRST_AAB=$(find "$ARTIFACTS_DIR" -name "*.aab" -type f | sort | head -n 1)');
466
+ commands.push('if [ -n "$FIRST_APK" ]; then');
467
+ commands.push(' envman add --key CIBUILD_APK_PATH --value "$FIRST_APK"');
468
+ commands.push(' echo "Exported CIBUILD_APK_PATH=$FIRST_APK"');
469
+ commands.push('fi');
470
+ commands.push('if [ -n "$FIRST_AAB" ]; then');
471
+ commands.push(' envman add --key CIBUILD_AAB_PATH --value "$FIRST_AAB"');
472
+ commands.push(' echo "Exported CIBUILD_AAB_PATH=$FIRST_AAB"');
473
+ commands.push('fi');
474
+ const script = this.createBashScriptFromCommands(commands, stepName);
475
+ return this.createScriptStep(script, stepName);
476
+ }
477
+ }
478
+ /**
479
+ * Android lint step executor
480
+ * Runs Android lint checks
481
+ */
482
+ export class AndroidLintStepExecutor extends BaseStepExecutor {
483
+ getValidationRequirements(_inputs, env, _config) {
484
+ return [
485
+ this.requireEnvVar('JAVA_HOME', 'Java installation directory', env, 'Add a set-java-version step before android-lint, or set JAVA_HOME env var'),
486
+ this.runtimeRequirement('gradlew', 'Gradle wrapper (./gradlew) or gradle command', 'file', 'git-clone'),
487
+ ];
488
+ }
489
+ async execute(inputs, env, config) {
490
+ const stepName = 'android-lint';
491
+ // Get project location from YAML input (if explicitly specified)
492
+ const explicitLocation = this.getInput(inputs, 'project_location', '');
493
+ // Get module - defaults to app
494
+ const module = this.getInput(inputs, 'module', 'app');
495
+ // Get variant - defaults to debug
496
+ const variant = this.getInput(inputs, 'variant', 'debug');
497
+ const commands = [];
498
+ commands.push('# Android Lint');
499
+ commands.push('');
500
+ // Add JAVA_HOME validation and auto-detection
501
+ commands.push('# Validate and auto-detect JAVA_HOME if needed');
502
+ commands.push('if [ -n "$JAVA_HOME" ] && [ ! -d "$JAVA_HOME" ]; then');
503
+ commands.push(' echo "⚠️ JAVA_HOME is set but points to invalid directory: $JAVA_HOME"');
504
+ commands.push(' ');
505
+ commands.push(' # Extract Java version from invalid path (e.g., "11" from /usr/lib/jvm/java-11-openjdk-amd64)');
506
+ commands.push(' REQUESTED_VERSION=$(echo "$JAVA_HOME" | grep -oE "java-[0-9]+" | grep -oE "[0-9]+" || echo "")');
507
+ commands.push(' if [ -z "$REQUESTED_VERSION" ]; then');
508
+ commands.push(' # Try alternative patterns (e.g., openjdk@17, openjdk-17)');
509
+ commands.push(' REQUESTED_VERSION=$(echo "$JAVA_HOME" | grep -oE "(openjdk[@-])[0-9]+" | grep -oE "[0-9]+" || echo "")');
510
+ commands.push(' fi');
511
+ commands.push(' ');
512
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
513
+ commands.push(' echo "Detected requested Java version: $REQUESTED_VERSION"');
514
+ commands.push(' echo "Attempting to find Java $REQUESTED_VERSION on this system..."');
515
+ commands.push(' else');
516
+ commands.push(' echo "Could not detect Java version from path, will try to find any Java..."');
517
+ commands.push(' fi');
518
+ commands.push(' echo ""');
519
+ commands.push(' ');
520
+ commands.push(' # Try to auto-detect Java for the requested version');
521
+ commands.push(' DETECTED_JAVA_HOME=""');
522
+ commands.push(' ');
523
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
524
+ commands.push(' # Check Homebrew installation paths for specific version (Apple Silicon)');
525
+ commands.push(' if [ -d "/opt/homebrew/opt/openjdk@${REQUESTED_VERSION}" ]; then');
526
+ commands.push(' DETECTED_JAVA_HOME="/opt/homebrew/opt/openjdk@${REQUESTED_VERSION}"');
527
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Homebrew Apple Silicon)"');
528
+ commands.push(' # Check Homebrew installation paths (Intel Mac)');
529
+ commands.push(' elif [ -d "/usr/local/opt/openjdk@${REQUESTED_VERSION}" ]; then');
530
+ commands.push(' DETECTED_JAVA_HOME="/usr/local/opt/openjdk@${REQUESTED_VERSION}"');
531
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Homebrew Intel)"');
532
+ commands.push(' # Check Android Studio JBR');
533
+ commands.push(' elif [ -d "/Applications/Android Studio.app/Contents/jbr/Contents/Home" ]; then');
534
+ commands.push(' JBR_PATH="/Applications/Android Studio.app/Contents/jbr/Contents/Home"');
535
+ commands.push(' JBR_MAJOR=$(grep "^JAVA_VERSION=" "$JBR_PATH/release" 2>/dev/null | grep -oE \'"[0-9]+\' | tr -d \'"\' || echo "")');
536
+ commands.push(' if [ "$JBR_MAJOR" = "$REQUESTED_VERSION" ]; then');
537
+ commands.push(' DETECTED_JAVA_HOME="$JBR_PATH"');
538
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Android Studio JBR)"');
539
+ commands.push(' fi');
540
+ commands.push(' # Try macOS java_home utility for specific version');
541
+ commands.push(' elif [ -x "/usr/libexec/java_home" ]; then');
542
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home -v "${REQUESTED_VERSION}" 2>/dev/null || true)');
543
+ commands.push(' if [ -z "$DETECTED_JAVA_HOME" ]; then');
544
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home -v "${REQUESTED_VERSION}.*" 2>/dev/null || true)');
545
+ commands.push(' fi');
546
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ]; then');
547
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (java_home utility)"');
548
+ commands.push(' fi');
549
+ commands.push(' fi');
550
+ commands.push(' fi');
551
+ commands.push(' ');
552
+ commands.push(' # If specific version not found, try any Java as fallback');
553
+ commands.push(' if [ -z "$DETECTED_JAVA_HOME" ]; then');
554
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
555
+ commands.push(' echo "⚠️ Java $REQUESTED_VERSION not found, checking for other versions..."');
556
+ commands.push(' fi');
557
+ commands.push(' ');
558
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
559
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home 2>/dev/null || true)');
560
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ]; then');
561
+ commands.push(' FALLBACK_VERSION=$("$DETECTED_JAVA_HOME/bin/java" -version 2>&1 | head -n 1 | grep -oE "[0-9]+" | head -n 1)');
562
+ commands.push(' echo "⚠️ Found Java $FALLBACK_VERSION instead of requested version $REQUESTED_VERSION"');
563
+ commands.push(' echo " Location: $DETECTED_JAVA_HOME"');
564
+ commands.push(' echo " ⚠️ WARNING: This may cause build issues if Java $REQUESTED_VERSION is required"');
565
+ commands.push(' fi');
566
+ commands.push(' fi');
567
+ commands.push(' fi');
568
+ commands.push(' ');
569
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ] && [ -d "$DETECTED_JAVA_HOME" ]; then');
570
+ commands.push(' export JAVA_HOME="$DETECTED_JAVA_HOME"');
571
+ commands.push(' echo "✅ Auto-corrected JAVA_HOME to: $JAVA_HOME"');
572
+ commands.push(' echo ""');
573
+ commands.push(' else');
574
+ commands.push(' echo ""');
575
+ commands.push(' echo "❌ Could not auto-detect valid Java installation"');
576
+ commands.push(' echo ""');
577
+ commands.push(' echo "JAVA_HOME is set to: $JAVA_HOME"');
578
+ commands.push(' echo "But this directory does not exist on your system."');
579
+ commands.push(' echo ""');
580
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
581
+ commands.push(' echo "Required Java version: $REQUESTED_VERSION"');
582
+ commands.push(' echo ""');
583
+ commands.push(' fi');
584
+ commands.push(' echo "To fix this issue:"');
585
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
586
+ commands.push(' echo " 1. Check available Java versions:"');
587
+ commands.push(' echo " /usr/libexec/java_home -V"');
588
+ commands.push(' echo ""');
589
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
590
+ commands.push(' echo " 2. Install Java $REQUESTED_VERSION via Homebrew:"');
591
+ commands.push(' echo " brew install openjdk@$REQUESTED_VERSION"');
592
+ commands.push(' else');
593
+ commands.push(' echo " 2. Install Java via Homebrew:"');
594
+ commands.push(' echo " brew install openjdk@17"');
595
+ commands.push(' fi');
596
+ commands.push(' echo ""');
597
+ commands.push(' echo " 3. Update JAVA_HOME in your secrets or add set-java-version step"');
598
+ commands.push(' else');
599
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
600
+ commands.push(' echo " 1. Install Java $REQUESTED_VERSION (Ubuntu/Debian):"');
601
+ commands.push(' echo " sudo apt-get install openjdk-${REQUESTED_VERSION}-jdk"');
602
+ commands.push(' else');
603
+ commands.push(' echo " 1. Install Java (Ubuntu/Debian):"');
604
+ commands.push(' echo " sudo apt-get install openjdk-17-jdk"');
605
+ commands.push(' fi');
606
+ commands.push(' echo ""');
607
+ commands.push(' echo " 2. Update JAVA_HOME in your secrets or add set-java-version step"');
608
+ commands.push(' fi');
609
+ commands.push(' echo ""');
610
+ commands.push(' exit 1');
611
+ commands.push(' fi');
612
+ commands.push('fi');
613
+ commands.push('');
614
+ // Determine project location at runtime: explicit > CIBUILD_SOURCE_DIR > current dir
615
+ if (explicitLocation && explicitLocation !== '.') {
616
+ commands.push(`PROJECT_DIR='${this.escapeBash(explicitLocation)}'`);
617
+ }
618
+ else {
619
+ commands.push('PROJECT_DIR="${CIBUILD_SOURCE_DIR:-.}"');
620
+ }
621
+ commands.push('echo "Project directory: $PROJECT_DIR"');
622
+ commands.push(`echo "Running lint on module: ${this.escapeBash(module)}"`);
623
+ commands.push(`echo "Variant: ${this.escapeBash(variant)}"`);
624
+ // Change to project directory
625
+ commands.push('');
626
+ commands.push('if [ "$PROJECT_DIR" != "." ]; then');
627
+ commands.push(' cd "$PROJECT_DIR"');
628
+ commands.push('fi');
629
+ // Make gradlew executable
630
+ commands.push('');
631
+ commands.push('# Make gradlew executable');
632
+ commands.push('if [ -f "./gradlew" ]; then');
633
+ commands.push(' chmod +x ./gradlew');
634
+ commands.push(' GRADLE_CMD="./gradlew"');
635
+ commands.push('elif command -v gradle &> /dev/null; then');
636
+ commands.push(' GRADLE_CMD="gradle"');
637
+ commands.push('else');
638
+ commands.push(' echo "Error: Neither ./gradlew nor gradle command found"');
639
+ commands.push(' exit 1');
640
+ commands.push('fi');
641
+ // Build lint task name
642
+ commands.push('');
643
+ commands.push('# Run lint');
644
+ const variantCapitalized = variant.charAt(0).toUpperCase() + variant.slice(1);
645
+ const lintTask = `:${this.escapeBash(module)}:lint${variantCapitalized}`;
646
+ commands.push(`$GRADLE_CMD ${lintTask}`);
647
+ commands.push('');
648
+ commands.push('# Lint completed');
649
+ commands.push('echo "Lint analysis completed successfully"');
650
+ commands.push(`echo "Lint report location: ${this.escapeBash(module)}/build/reports/lint-results-${this.escapeBash(variant)}.html"`);
651
+ const script = this.createBashScriptFromCommands(commands, stepName);
652
+ return this.createScriptStep(script, stepName);
653
+ }
654
+ }
655
+ /**
656
+ * Android unit test step executor
657
+ * Runs Android unit tests
658
+ */
659
+ export class AndroidUnitTestStepExecutor extends BaseStepExecutor {
660
+ getValidationRequirements(_inputs, env, _config) {
661
+ return [
662
+ this.requireEnvVar('JAVA_HOME', 'Java installation directory', env, 'Add a set-java-version step before android-unit-test, or set JAVA_HOME env var'),
663
+ this.runtimeRequirement('gradlew', 'Gradle wrapper (./gradlew) or gradle command', 'file', 'git-clone'),
664
+ ];
665
+ }
666
+ async execute(inputs, env, config) {
667
+ const stepName = 'android-unit-test';
668
+ // Get project location from YAML input (if explicitly specified)
669
+ const explicitLocation = this.getInput(inputs, 'project_location', '');
670
+ // Get module - defaults to app
671
+ const module = this.getInput(inputs, 'module', 'app');
672
+ // Get variant - defaults to debug
673
+ const variant = this.getInput(inputs, 'variant', 'debug');
674
+ // Get test filter - optional
675
+ const testFilter = this.getInput(inputs, 'test_filter', '');
676
+ const commands = [];
677
+ commands.push('# Android Unit Tests');
678
+ commands.push('');
679
+ // Add JAVA_HOME validation and auto-detection
680
+ commands.push('# Validate and auto-detect JAVA_HOME if needed');
681
+ commands.push('if [ -n "$JAVA_HOME" ] && [ ! -d "$JAVA_HOME" ]; then');
682
+ commands.push(' echo "⚠️ JAVA_HOME is set but points to invalid directory: $JAVA_HOME"');
683
+ commands.push(' ');
684
+ commands.push(' # Extract Java version from invalid path (e.g., "11" from /usr/lib/jvm/java-11-openjdk-amd64)');
685
+ commands.push(' REQUESTED_VERSION=$(echo "$JAVA_HOME" | grep -oE "java-[0-9]+" | grep -oE "[0-9]+" || echo "")');
686
+ commands.push(' if [ -z "$REQUESTED_VERSION" ]; then');
687
+ commands.push(' # Try alternative patterns (e.g., openjdk@17, openjdk-17)');
688
+ commands.push(' REQUESTED_VERSION=$(echo "$JAVA_HOME" | grep -oE "(openjdk[@-])[0-9]+" | grep -oE "[0-9]+" || echo "")');
689
+ commands.push(' fi');
690
+ commands.push(' ');
691
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
692
+ commands.push(' echo "Detected requested Java version: $REQUESTED_VERSION"');
693
+ commands.push(' echo "Attempting to find Java $REQUESTED_VERSION on this system..."');
694
+ commands.push(' else');
695
+ commands.push(' echo "Could not detect Java version from path, will try to find any Java..."');
696
+ commands.push(' fi');
697
+ commands.push(' echo ""');
698
+ commands.push(' ');
699
+ commands.push(' # Try to auto-detect Java for the requested version');
700
+ commands.push(' DETECTED_JAVA_HOME=""');
701
+ commands.push(' ');
702
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
703
+ commands.push(' # Check Homebrew installation paths for specific version (Apple Silicon)');
704
+ commands.push(' if [ -d "/opt/homebrew/opt/openjdk@${REQUESTED_VERSION}" ]; then');
705
+ commands.push(' DETECTED_JAVA_HOME="/opt/homebrew/opt/openjdk@${REQUESTED_VERSION}"');
706
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Homebrew Apple Silicon)"');
707
+ commands.push(' # Check Homebrew installation paths (Intel Mac)');
708
+ commands.push(' elif [ -d "/usr/local/opt/openjdk@${REQUESTED_VERSION}" ]; then');
709
+ commands.push(' DETECTED_JAVA_HOME="/usr/local/opt/openjdk@${REQUESTED_VERSION}"');
710
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Homebrew Intel)"');
711
+ commands.push(' # Check Android Studio JBR');
712
+ commands.push(' elif [ -d "/Applications/Android Studio.app/Contents/jbr/Contents/Home" ]; then');
713
+ commands.push(' JBR_PATH="/Applications/Android Studio.app/Contents/jbr/Contents/Home"');
714
+ commands.push(' JBR_MAJOR=$(grep "^JAVA_VERSION=" "$JBR_PATH/release" 2>/dev/null | grep -oE \'"[0-9]+\' | tr -d \'"\' || echo "")');
715
+ commands.push(' if [ "$JBR_MAJOR" = "$REQUESTED_VERSION" ]; then');
716
+ commands.push(' DETECTED_JAVA_HOME="$JBR_PATH"');
717
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (Android Studio JBR)"');
718
+ commands.push(' fi');
719
+ commands.push(' # Try macOS java_home utility for specific version');
720
+ commands.push(' elif [ -x "/usr/libexec/java_home" ]; then');
721
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home -v "${REQUESTED_VERSION}" 2>/dev/null || true)');
722
+ commands.push(' if [ -z "$DETECTED_JAVA_HOME" ]; then');
723
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home -v "${REQUESTED_VERSION}.*" 2>/dev/null || true)');
724
+ commands.push(' fi');
725
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ]; then');
726
+ commands.push(' echo "✅ Found Java $REQUESTED_VERSION at: $DETECTED_JAVA_HOME (java_home utility)"');
727
+ commands.push(' fi');
728
+ commands.push(' fi');
729
+ commands.push(' fi');
730
+ commands.push(' ');
731
+ commands.push(' # If specific version not found, try any Java as fallback');
732
+ commands.push(' if [ -z "$DETECTED_JAVA_HOME" ]; then');
733
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
734
+ commands.push(' echo "⚠️ Java $REQUESTED_VERSION not found, checking for other versions..."');
735
+ commands.push(' fi');
736
+ commands.push(' ');
737
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
738
+ commands.push(' DETECTED_JAVA_HOME=$(/usr/libexec/java_home 2>/dev/null || true)');
739
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ]; then');
740
+ commands.push(' FALLBACK_VERSION=$("$DETECTED_JAVA_HOME/bin/java" -version 2>&1 | head -n 1 | grep -oE "[0-9]+" | head -n 1)');
741
+ commands.push(' echo "⚠️ Found Java $FALLBACK_VERSION instead of requested version $REQUESTED_VERSION"');
742
+ commands.push(' echo " Location: $DETECTED_JAVA_HOME"');
743
+ commands.push(' echo " ⚠️ WARNING: This may cause build issues if Java $REQUESTED_VERSION is required"');
744
+ commands.push(' fi');
745
+ commands.push(' fi');
746
+ commands.push(' fi');
747
+ commands.push(' ');
748
+ commands.push(' if [ -n "$DETECTED_JAVA_HOME" ] && [ -d "$DETECTED_JAVA_HOME" ]; then');
749
+ commands.push(' export JAVA_HOME="$DETECTED_JAVA_HOME"');
750
+ commands.push(' echo "✅ Auto-corrected JAVA_HOME to: $JAVA_HOME"');
751
+ commands.push(' echo ""');
752
+ commands.push(' else');
753
+ commands.push(' echo ""');
754
+ commands.push(' echo "❌ Could not auto-detect valid Java installation"');
755
+ commands.push(' echo ""');
756
+ commands.push(' echo "JAVA_HOME is set to: $JAVA_HOME"');
757
+ commands.push(' echo "But this directory does not exist on your system."');
758
+ commands.push(' echo ""');
759
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
760
+ commands.push(' echo "Required Java version: $REQUESTED_VERSION"');
761
+ commands.push(' echo ""');
762
+ commands.push(' fi');
763
+ commands.push(' echo "To fix this issue:"');
764
+ commands.push(' if [ -x "/usr/libexec/java_home" ]; then');
765
+ commands.push(' echo " 1. Check available Java versions:"');
766
+ commands.push(' echo " /usr/libexec/java_home -V"');
767
+ commands.push(' echo ""');
768
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
769
+ commands.push(' echo " 2. Install Java $REQUESTED_VERSION via Homebrew:"');
770
+ commands.push(' echo " brew install openjdk@$REQUESTED_VERSION"');
771
+ commands.push(' else');
772
+ commands.push(' echo " 2. Install Java via Homebrew:"');
773
+ commands.push(' echo " brew install openjdk@17"');
774
+ commands.push(' fi');
775
+ commands.push(' echo ""');
776
+ commands.push(' echo " 3. Update JAVA_HOME in your secrets or add set-java-version step"');
777
+ commands.push(' else');
778
+ commands.push(' if [ -n "$REQUESTED_VERSION" ]; then');
779
+ commands.push(' echo " 1. Install Java $REQUESTED_VERSION (Ubuntu/Debian):"');
780
+ commands.push(' echo " sudo apt-get install openjdk-${REQUESTED_VERSION}-jdk"');
781
+ commands.push(' else');
782
+ commands.push(' echo " 1. Install Java (Ubuntu/Debian):"');
783
+ commands.push(' echo " sudo apt-get install openjdk-17-jdk"');
784
+ commands.push(' fi');
785
+ commands.push(' echo ""');
786
+ commands.push(' echo " 2. Update JAVA_HOME in your secrets or add set-java-version step"');
787
+ commands.push(' fi');
788
+ commands.push(' echo ""');
789
+ commands.push(' exit 1');
790
+ commands.push(' fi');
791
+ commands.push('fi');
792
+ commands.push('');
793
+ // Determine project location at runtime: explicit > CIBUILD_SOURCE_DIR > current dir
794
+ if (explicitLocation && explicitLocation !== '.') {
795
+ commands.push(`PROJECT_DIR='${this.escapeBash(explicitLocation)}'`);
796
+ }
797
+ else {
798
+ commands.push('PROJECT_DIR="${CIBUILD_SOURCE_DIR:-.}"');
799
+ }
800
+ commands.push('echo "Project directory: $PROJECT_DIR"');
801
+ commands.push(`echo "Running unit tests on module: ${this.escapeBash(module)}"`);
802
+ commands.push(`echo "Variant: ${this.escapeBash(variant)}"`);
803
+ // Change to project directory
804
+ commands.push('');
805
+ commands.push('if [ "$PROJECT_DIR" != "." ]; then');
806
+ commands.push(' cd "$PROJECT_DIR"');
807
+ commands.push('fi');
808
+ // Make gradlew executable
809
+ commands.push('');
810
+ commands.push('# Make gradlew executable');
811
+ commands.push('if [ -f "./gradlew" ]; then');
812
+ commands.push(' chmod +x ./gradlew');
813
+ commands.push(' GRADLE_CMD="./gradlew"');
814
+ commands.push('elif command -v gradle &> /dev/null; then');
815
+ commands.push(' GRADLE_CMD="gradle"');
816
+ commands.push('else');
817
+ commands.push(' echo "Error: Neither ./gradlew nor gradle command found"');
818
+ commands.push(' exit 1');
819
+ commands.push('fi');
820
+ // Build test task name
821
+ commands.push('');
822
+ commands.push('# Run unit tests');
823
+ const variantCapitalized = variant.charAt(0).toUpperCase() + variant.slice(1);
824
+ const testTask = `:${this.escapeBash(module)}:test${variantCapitalized}UnitTest`;
825
+ let gradleCmd = `$GRADLE_CMD ${testTask}`;
826
+ // Add test filter if specified
827
+ if (testFilter && testFilter.trim() !== '') {
828
+ gradleCmd += ` --tests '${this.escapeBash(testFilter)}'`;
829
+ }
830
+ commands.push(gradleCmd);
831
+ commands.push('');
832
+ commands.push('# Tests completed');
833
+ commands.push('echo "Unit tests completed successfully"');
834
+ commands.push(`echo "Test report location: ${this.escapeBash(module)}/build/reports/tests/test${variantCapitalized}UnitTest/index.html"`);
835
+ const script = this.createBashScriptFromCommands(commands, stepName);
836
+ return this.createScriptStep(script, stepName);
837
+ }
838
+ }
839
+ /**
840
+ * Builds app APK and test APK for Android instrumented (UI) tests.
841
+ * Runs assembleVariant and assembleVariantAndroidTest gradle tasks.
842
+ */
843
+ export class AndroidBuildForUITestingStepExecutor extends BaseStepExecutor {
844
+ getValidationRequirements(_inputs, env, _config) {
845
+ return [
846
+ this.requireEnvVar('JAVA_HOME', 'Java installation directory', env, 'Add a set-java-version step before this step'),
847
+ ];
848
+ }
849
+ getOutputs() {
850
+ return [
851
+ { name: 'CIBUILD_APK_PATH', type: 'environment', description: 'Path to the app APK' },
852
+ { name: 'CIBUILD_TEST_APK_PATH', type: 'environment', description: 'Path to the test APK' },
853
+ ];
854
+ }
855
+ async execute(inputs, _env, _config) {
856
+ const stepName = 'android-build-for-ui-testing';
857
+ const projectLocation = this.getInput(inputs, 'project_location', '.');
858
+ const module = this.getInput(inputs, 'module', 'app');
859
+ const variant = this.getInput(inputs, 'variant', 'Debug');
860
+ const extraArgs = this.getInput(inputs, 'arguments', '');
861
+ const variantCap = variant.charAt(0).toUpperCase() + variant.slice(1);
862
+ const commands = [];
863
+ commands.push('# android-build-for-ui-testing');
864
+ commands.push('echo "🧪 Building for UI testing..."');
865
+ commands.push('');
866
+ // Navigate to project
867
+ if (projectLocation !== '.') {
868
+ commands.push(`cd '${this.escapeBash(projectLocation)}'`);
869
+ }
870
+ else {
871
+ commands.push('if [ -n "$CIBUILD_SOURCE_DIR" ]; then cd "$CIBUILD_SOURCE_DIR"; fi');
872
+ }
873
+ commands.push('');
874
+ // gradlew
875
+ commands.push('if [ -f "./gradlew" ]; then');
876
+ commands.push(' chmod +x ./gradlew');
877
+ commands.push(' GRADLE_CMD="./gradlew"');
878
+ commands.push('else');
879
+ commands.push(' GRADLE_CMD="gradle"');
880
+ commands.push('fi');
881
+ commands.push('');
882
+ // Build both app and test APKs
883
+ const appTask = `:${this.escapeBash(module)}:assemble${variantCap}`;
884
+ const testTask = `:${this.escapeBash(module)}:assemble${variantCap}AndroidTest`;
885
+ let cmd = `$GRADLE_CMD ${appTask} ${testTask}`;
886
+ if (extraArgs) {
887
+ cmd += ` ${extraArgs}`;
888
+ }
889
+ commands.push(`echo "Running: ${cmd}"`);
890
+ commands.push(cmd);
891
+ commands.push('');
892
+ // Locate APKs
893
+ commands.push('# Locate generated APKs');
894
+ commands.push(`APP_APK=$(find . -path "*/${this.escapeBash(module)}/build/outputs/apk/*/*.apk" ! -name "*androidTest*" | head -1)`);
895
+ commands.push(`TEST_APK=$(find . -path "*/${this.escapeBash(module)}/build/outputs/apk/*/*.apk" -name "*androidTest*" | head -1)`);
896
+ commands.push('');
897
+ commands.push('if [ -z "$APP_APK" ]; then');
898
+ commands.push(' echo "⚠️ App APK not found"');
899
+ commands.push('else');
900
+ commands.push(' echo "App APK: $APP_APK"');
901
+ commands.push(' envman add --key CIBUILD_APK_PATH --value "$APP_APK"');
902
+ commands.push('fi');
903
+ commands.push('');
904
+ commands.push('if [ -z "$TEST_APK" ]; then');
905
+ commands.push(' echo "⚠️ Test APK not found"');
906
+ commands.push('else');
907
+ commands.push(' echo "Test APK: $TEST_APK"');
908
+ commands.push(' envman add --key CIBUILD_TEST_APK_PATH --value "$TEST_APK"');
909
+ commands.push('fi');
910
+ commands.push('');
911
+ commands.push('echo "✅ UI testing build complete"');
912
+ const script = this.createBashScriptFromCommands(commands, stepName);
913
+ return this.createScriptStep(script, stepName);
914
+ }
915
+ }
916
+ //# sourceMappingURL=android.js.map