47 lines
2.3 KiB
PowerShell
47 lines
2.3 KiB
PowerShell
# Сборка и деплой SPP-сервера одной командой (Windows).
|
|
# powershell -ExecutionPolicy Bypass -File build.ps1 # ant jar + деплой в server\ + restart game
|
|
# powershell -ExecutionPolicy Bypass -File build.ps1 -NoRestart # только собрать и разложить файлы
|
|
# powershell -ExecutionPolicy Bypass -File build.ps1 -DeployOnly # без сборки: только данные/конфиги/скрипты
|
|
# Нужны JDK 25 (JAVA_HOME) и Apache Ant в PATH.
|
|
param(
|
|
[switch]$NoRestart,
|
|
[switch]$DeployOnly
|
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
$Base = $PSScriptRoot
|
|
$Src = Join-Path $Base "src_mobius\mobius\L2J_Mobius_CT_0_Interlude"
|
|
$Build = Join-Path $Base "src_mobius\mobius\build\dist\libs"
|
|
$Server = Join-Path $Base "server"
|
|
$Compose = Join-Path $Server "docker\docker-compose.yml"
|
|
|
|
if (-not $DeployOnly) {
|
|
Push-Location $Src
|
|
try {
|
|
Write-Host "ant jar..." -ForegroundColor Cyan
|
|
ant -q jar
|
|
if ($LASTEXITCODE -ne 0) { throw "ant failed" }
|
|
} finally { Pop-Location }
|
|
Copy-Item (Join-Path $Build "GameServer.jar") (Join-Path $Server "libs\GameServer.jar") -Force
|
|
Copy-Item (Join-Path $Build "LoginServer.jar") (Join-Path $Server "libs\LoginServer.jar") -Force
|
|
Write-Host "jar -> server\libs" -ForegroundColor Green
|
|
}
|
|
|
|
# Оверлей датапака: данные ботов, конфиги, чат-хендлеры, SQL-сиды. libs не копируем (это зависимости сборки).
|
|
$Dist = Join-Path $Src "dist"
|
|
Get-ChildItem -Path $Dist -Recurse -File | Where-Object { $_.FullName -notlike "*\dist\libs\*" } | ForEach-Object {
|
|
$rel = $_.FullName.Substring($Dist.Length + 1)
|
|
$dst = Join-Path $Server $rel
|
|
New-Item -ItemType Directory -Force -Path (Split-Path $dst) | Out-Null
|
|
Copy-Item $_.FullName $dst -Force
|
|
}
|
|
Write-Host "оверлей -> server\ (data, config, scripts, sql)" -ForegroundColor Green
|
|
|
|
if (-not $NoRestart) {
|
|
if (Test-Path $Compose) {
|
|
docker compose -f $Compose restart game
|
|
Write-Host "game перезапущен. Лог: docker compose -f server\docker\docker-compose.yml logs -f game" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "docker-compose не найден, перезапусти сервер вручную." -ForegroundColor Yellow
|
|
}
|
|
}
|