param( [string]$ProjectRoot = (Resolve-Path "$PSScriptRoot\..").Path, [string]$ProjectFile = "swarm.b4a", [string]$BuilderPath = "C:\Program Files\Anywhere Software\B4A\B4ABuilder.exe", [ValidateSet("Build", "BuildBundle", "BuildLibrary")] [string]$Task = "Build", [switch]$NoSign, [switch]$Obfuscate, [switch]$NoClean, [string]$Configuration = "", [string]$Output = "" ) $ErrorActionPreference = "Stop" if (-not (Test-Path -LiteralPath $BuilderPath)) { throw "B4ABuilder.exe non trovato: $BuilderPath" } if (-not (Test-Path -LiteralPath (Join-Path $ProjectRoot $ProjectFile))) { throw "Progetto B4A non trovato: $(Join-Path $ProjectRoot $ProjectFile)" } $arguments = @( "-Task=$Task", "-BaseFolder=$ProjectRoot", "-Project=$ProjectFile", "-Obfuscate=$($Obfuscate.IsPresent)", "-ShowWarnings=True", "-NoSign=$($NoSign.IsPresent)", "-NoClean=$($NoClean.IsPresent)" ) if ($Configuration.Trim().Length -gt 0) { $arguments += "-Configuration=$Configuration" } if ($Output.Trim().Length -gt 0) { $arguments += "-Output=$Output" } Write-Host "B4A build: $ProjectFile" Write-Host "Root: $ProjectRoot" Write-Host "" & $BuilderPath @arguments $exitCode = $LASTEXITCODE if ($exitCode -ne 0) { throw "Build B4A fallita. Exit code: $exitCode" }