param([switch]$SkipWebBuild) $ErrorActionPreference='Stop' $taskRoot=(Resolve-Path (Join-Path $PSScriptRoot '../..')).Path $env:JAVA_HOME=Join-Path $env:USERPROFILE '.jdks/ms-17.0.19' $env:ANDROID_HOME=Join-Path $taskRoot '.codex-tmp/android-sdk' $env:GRADLE_USER_HOME=Join-Path $taskRoot '.codex-tmp/gradle-cache' $taskSocketDirectory=(Join-Path $taskRoot '.codex-tmp').Replace('\','/') $env:GRADLE_OPTS="-Djdk.net.unixdomain.tmpdir=$taskSocketDirectory" $env:JAVA_TOOL_OPTIONS="-Djdk.net.unixdomain.tmpdir=$taskSocketDirectory" $taskGradle=Join-Path $taskRoot '.codex-tmp/android-tools/gradle-8.11.1/bin/gradle.bat' if (!(Test-Path -LiteralPath $taskGradle)) { throw 'Install Gradle 8.11.1 in the local android-tools directory.' } if (!$SkipWebBuild) { Push-Location (Join-Path $taskRoot 'ruoyi-ui-vue3') try {$env:NODE_OPTIONS='--max-old-space-size=1024'; & 'C:/Program Files/nodejs/node.exe' 'node_modules/vite/bin/vite.js' build; if($LASTEXITCODE -ne 0){throw 'Web build failed'}} finally {Pop-Location} } $taskAssets=Join-Path $taskRoot 'android-app/app/src/main/assets' New-Item -ItemType Directory -Path $taskAssets -Force | Out-Null $taskBundle=Join-Path $taskAssets 'web.zip' $taskWebFiles=Get-ChildItem -LiteralPath (Join-Path $taskRoot 'ruoyi-ui-vue3/dist') | Where-Object { $_.Name -ne 'mobile-update.json' -and $_.Name -notmatch '^web-[a-f0-9]+\.zip$' } | Select-Object -ExpandProperty FullName Compress-Archive -Path $taskWebFiles -DestinationPath $taskBundle -Force & 'C:/Program Files/nodejs/node.exe' (Join-Path $PSScriptRoot 'mobile-update.cjs') if($LASTEXITCODE -ne 0){throw 'Page update packaging failed'} Push-Location (Join-Path $taskRoot 'android-app') try {& $taskGradle "-Dorg.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -Djdk.net.unixdomain.tmpdir=$taskSocketDirectory" --no-daemon testDebugUnitTest assembleDebug; if($LASTEXITCODE -ne 0){throw 'Android build or tests failed'}} finally {Pop-Location} Write-Output (Join-Path $taskRoot 'android-app/app/build/outputs/apk/debug/app-debug.apk')