19 lines
960 B
PowerShell
19 lines
960 B
PowerShell
[CmdletBinding()]
|
|||
|
|
param([string]$JavaHome, [string]$MavenPath, [string]$NodePath, [switch]$SkipFrontend)
|
||
|
|
. (Join-Path $PSScriptRoot 'Common.ps1')
|
||
|
|
$projectRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
|
||
|
|
$java = Get-XtrhJava -JavaHome $JavaHome
|
||
|
|
$env:JAVA_HOME = Split-Path -Parent (Split-Path -Parent $java)
|
||
|
|
if (-not $MavenPath) {
|
||
|
|
$maven = Get-Command mvn.cmd -ErrorAction SilentlyContinue
|
||
|
|
if ($maven) { $MavenPath = $maven.Source }
|
||
|
|
}
|
||
|
|
if (-not $MavenPath -or -not (Test-Path -LiteralPath $MavenPath)) { throw '请通过 -MavenPath 指定 mvn.cmd,或将 Maven 加入 PATH。' }
|
||
|
|
if (-not $SkipFrontend) { & (Join-Path $PSScriptRoot 'Build-Console.ps1') -NodePath $NodePath }
|
||
|
|
Push-Location $projectRoot
|
||
|
|
try {
|
||
|
|
& $MavenPath '-B' 'verify'
|
||
|
|
if ($LASTEXITCODE -ne 0) { throw 'Java 构建或测试失败。' }
|
||
|
|
} finally { Pop-Location }
|
||
|
|
Write-Output ('构建完成:' + (Join-Path $projectRoot 'target/xtrh-services-1.0.0.jar'))
|