37 lines
1.5 KiB
PowerShell
37 lines
1.5 KiB
PowerShell
# Windows/PowerShell build entry point. GlassFish may run on Windows or Linux;
|
|
# the generated WAR and browser-side CheerpJ code are OS independent.
|
|
[CmdletBinding()]
|
|
param()
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
function Find-Tool([string[]]$Names) {
|
|
foreach ($name in $Names) {
|
|
$item = Get-Command $name -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($null -ne $item) { return $item.Source }
|
|
}
|
|
throw "Erforderliches Programm fehlt: $($Names -join ' oder ')"
|
|
}
|
|
function Run-Checked([string]$Tool, [string[]]$ToolArguments) {
|
|
& $Tool @ToolArguments
|
|
if ($LASTEXITCODE -ne 0) { throw "Fehler: $Tool $($ToolArguments -join ' ') (Exit-Code $LASTEXITCODE)" }
|
|
}
|
|
|
|
$npm = Find-Tool @('npm.cmd','npm')
|
|
$mvn = Find-Tool @('mvn.cmd','mvn.bat','mvn')
|
|
& (Join-Path $Root 'hmi-scripts/build-jaas-bridge.ps1')
|
|
& (Join-Path $Root 'hmi-scripts/build-native-loader-smoke.ps1')
|
|
Push-Location (Join-Path $Root 'hmi-frontend')
|
|
try {
|
|
if (Test-Path 'package-lock.json') { Run-Checked $npm @('ci') }
|
|
else { Run-Checked $npm @('install') }
|
|
Run-Checked $npm @('run','build')
|
|
} finally { Pop-Location }
|
|
Push-Location (Join-Path $Root 'backend')
|
|
try { Run-Checked $mvn @('clean','package') }
|
|
finally { Pop-Location }
|
|
$wars = @(Get-ChildItem -Path (Join-Path $Root 'backend/target') -Filter '*.war' -File)
|
|
if ($wars.Count -ne 1) { throw "Genau eine WAR erwartet: gefunden $($wars.Count)" }
|
|
Write-Host "Build erfolgreich. WAR: $($wars[0].FullName)"
|