# Builds rsx-server-core, which needs the other two on its classpath. # # ASCII only, for the same reason as the other scripts. $ErrorActionPreference = 'Stop' $Repo = Split-Path -Parent $PSScriptRoot if (-not $Repo) { $Repo = $PSCommandPath | Split-Path -Parent | Split-Path -Parent } $Workspace = Split-Path -Parent $Repo $Dist = Join-Path $Repo 'dist' $Out = Join-Path $Repo 'build' function Say($text) { Write-Host " $text" -ForegroundColor Cyan } $Protocol = Join-Path $Workspace 'rsx-protocol\build\classes' $Auth = Join-Path $Workspace 'rsx-auth\build\classes' $PluginApi = Join-Path $Workspace 'rsx-plugin-api\build\classes' foreach ($dep in @($Protocol, $Auth, $PluginApi)) { if (-not (Test-Path $dep)) { Write-Host " Missing dependency: $dep" -ForegroundColor Red Write-Host ' Build rsx-protocol, rsx-auth and rsx-plugin-api first.' -ForegroundColor Red exit 1 } } New-Item -ItemType Directory -Force -Path $Dist, $Out | Out-Null $mainOut = Join-Path $Out 'classes' Remove-Item $mainOut -Recurse -Force -ErrorAction SilentlyContinue New-Item -ItemType Directory -Force -Path $mainOut | Out-Null $mainFiles = @(Get-ChildItem (Join-Path $Repo 'src\main\java') -Recurse -Filter '*.java' | ForEach-Object { $_.FullName }) if ($mainFiles.Count -eq 0) { Write-Host ' No sources found.' -ForegroundColor Red; exit 1 } $cp = "$Protocol;$Auth;$PluginApi" & javac -encoding UTF-8 --release 17 -Xlint:-options -nowarn -cp $cp -d $mainOut $mainFiles if ($LASTEXITCODE -ne 0) { Write-Host ' Server failed to compile.' -ForegroundColor Red; exit 1 } Say "server compiled ($($mainFiles.Count) files)" $manifest = Join-Path $Out 'manifest.txt' @" Manifest-Version: 1.0 Implementation-Title: RustNotMC server Implementation-Version: 0.1.0 Class-Path: rsx-protocol.jar rsx-auth.jar rsx-plugin-api.jar "@ | Set-Content -LiteralPath $manifest -Encoding ASCII $jar = Join-Path $Dist 'rsx-server-core.jar' if (Test-Path -LiteralPath $jar) { Remove-Item -LiteralPath $jar -Force } & jar cfm $jar $manifest -C $mainOut . if ($LASTEXITCODE -ne 0) { Write-Host ' Could not package the jar.' -ForegroundColor Red; exit 1 } Say "rsx-server-core.jar ($((Get-Item $jar).Length) bytes)" Write-Host '' Write-Host ' Done:' -ForegroundColor Green Write-Host " $jar"