|
248 | 248 |
|
249 | 249 | # Idempotent app/build.gradle.kts dependency injection |
250 | 250 | APP_BUILD_GRADLE="src-tauri/gen/android/app/build.gradle.kts" |
251 | | -echo "Ensuring usb-serial-for-android dependency in app/build.gradle.kts..." |
| 251 | +echo "Ensuring usb-serial-for-android dependency and repositories in app/build.gradle.kts..." |
252 | 252 |
|
253 | 253 | if [ -f "$APP_BUILD_GRADLE" ]; then |
| 254 | + # Add repositories block to app/build.gradle.kts if missing |
| 255 | + if ! grep -q "^repositories {" "$APP_BUILD_GRADLE"; then |
| 256 | + echo "Adding repositories block to app/build.gradle.kts..." |
| 257 | + # Insert repositories block after plugins block |
| 258 | + awk ' |
| 259 | + /^plugins \{/ { |
| 260 | + print $0 |
| 261 | + in_plugins=1 |
| 262 | + next |
| 263 | + } |
| 264 | + in_plugins && /^\}/ { |
| 265 | + print $0 |
| 266 | + print "" |
| 267 | + print "repositories {" |
| 268 | + print " maven { url = uri(\"https://jitpack.io\") }" |
| 269 | + print "}" |
| 270 | + in_plugins=0 |
| 271 | + next |
| 272 | + } |
| 273 | + { print } |
| 274 | + ' "$APP_BUILD_GRADLE" > "$APP_BUILD_GRADLE.tmp" && mv "$APP_BUILD_GRADLE.tmp" "$APP_BUILD_GRADLE" |
| 275 | + else |
| 276 | + # Check if jitpack.io is already in repositories |
| 277 | + if ! grep -A 10 "^repositories {" "$APP_BUILD_GRADLE" | grep -q "jitpack.io"; then |
| 278 | + echo "Adding jitpack.io repository to existing repositories block..." |
| 279 | + # Insert jitpack.io repository into existing repositories block |
| 280 | + awk ' |
| 281 | + /^repositories \{/ { |
| 282 | + print $0 |
| 283 | + print " maven { url = uri(\"https://jitpack.io\") }" |
| 284 | + found=1 |
| 285 | + next |
| 286 | + } |
| 287 | + { print } |
| 288 | + ' "$APP_BUILD_GRADLE" > "$APP_BUILD_GRADLE.tmp" && mv "$APP_BUILD_GRADLE.tmp" "$APP_BUILD_GRADLE" |
| 289 | + fi |
| 290 | + fi |
| 291 | + |
254 | 292 | if ! grep -q "usb-serial-for-android" "$APP_BUILD_GRADLE"; then |
255 | 293 | echo "Adding usb-serial-for-android dependency to app module..." |
256 | 294 | # Find the dependencies block and add the dependency |
257 | 295 | if grep -q "^dependencies {" "$APP_BUILD_GRADLE"; then |
258 | 296 | # Insert after the opening dependencies { line |
259 | 297 | sed -i '/^dependencies {/a\ |
260 | | - implementation("com.github.mik3y:usb-serial-for-android:3.8.1") |
| 298 | + implementation("com.github.mik3y:usb-serial-for-android:3.8.0") |
261 | 299 | ' "$APP_BUILD_GRADLE" |
262 | 300 | else |
263 | 301 | # Create dependencies block if it doesn't exist |
264 | 302 | echo "Creating dependencies block with usb-serial-for-android..." |
265 | 303 | cat >> "$APP_BUILD_GRADLE" << 'EOF' |
266 | 304 |
|
267 | 305 | dependencies { |
268 | | - implementation("com.github.mik3y:usb-serial-for-android:3.8.1") |
| 306 | + implementation("com.github.mik3y:usb-serial-for-android:3.8.0") |
269 | 307 | } |
270 | 308 | EOF |
271 | 309 | fi |
|
0 commit comments