# Build debug APKs for notiMessage (app + xposed-module)
$ErrorActionPreference = "Stop"
$ProjectRoot = Split-Path -Parent $PSScriptRoot
Set-Location $ProjectRoot

$env:JAVA_HOME = "C:\Program Files\Java\jdk-17"
$javaHomeArg = "-Dorg.gradle.java.home=C:\Program Files\Java\jdk-17"
Write-Host "JAVA_HOME=$env:JAVA_HOME"
Write-Host "Building debug APKs..."
& "$ProjectRoot\gradlew.bat" $javaHomeArg :app:assembleDebug :xposed-module:assembleDebug
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

$appApk = Join-Path $ProjectRoot "app\build\outputs\apk\debug\app-debug.apk"
$xposedApk = Join-Path $ProjectRoot "xposed-module\build\outputs\apk\debug\xposed-module-debug.apk"

Write-Host ""
if (Test-Path $appApk) {
    Write-Host "App OK: $appApk"
} else {
    Write-Host "App APK not found." -ForegroundColor Yellow
}
if (Test-Path $xposedApk) {
    Write-Host "Xposed OK: $xposedApk"
} else {
    Write-Host "Xposed APK not found." -ForegroundColor Yellow
}
