# Builds the loader into dist\. # # Only a JDK is required. No Gradle, no network: the loader is compiled with # javac exactly the way the client will run it, with --release 17, because the # game ships its own Java 8 runtime and anything newer simply will not load. # # dist\rsx-loader.jar the loader and the mod API # # NOTE: this file is ASCII on purpose. Windows PowerShell 5.1 reads a .ps1 that # has no byte order mark using the system ANSI code page, which mangles UTF-8 # and makes the parser choke on non-ASCII text. Keep script messages English. $ErrorActionPreference = 'Stop' $Repo = Split-Path -Parent $PSScriptRoot if (-not $Repo) { $Repo = $PSCommandPath | Split-Path -Parent | Split-Path -Parent } $Dist = Join-Path $Repo 'dist' $Out = Join-Path $Repo 'build' function Say($text) { Write-Host " $text" -ForegroundColor Cyan } if (-not (Get-Command javac -ErrorAction SilentlyContinue)) { Write-Host ' A JDK (javac) is required.' -ForegroundColor Red exit 1 } New-Item -ItemType Directory -Force -Path $Dist, $Out | Out-Null # ---------------------------------------------------------------- loader $mainOut = Join-Path $Out 'classes' Remove-Item $mainOut -Recurse -Force -ErrorAction SilentlyContinue New-Item -ItemType Directory -Force -Path $mainOut | Out-Null $mainSrc = Join-Path $Repo 'src\main\java' $mainFiles = @(Get-ChildItem $mainSrc -Recurse -Filter '*.java' | ForEach-Object { $_.FullName }) if ($mainFiles.Count -eq 0) { Write-Host ' No sources found.' -ForegroundColor Red exit 1 } & javac -encoding UTF-8 --release 17 -Xlint:-options -nowarn -d $mainOut $mainFiles if ($LASTEXITCODE -ne 0) { Write-Host ' Loader failed to compile.' -ForegroundColor Red exit 1 } Say "loader compiled ($($mainFiles.Count) files)" $manifest = Join-Path $Out 'manifest.txt' @" Manifest-Version: 1.0 Implementation-Title: RustNotMC loader Implementation-Version: 0.1.0 "@ | Set-Content -LiteralPath $manifest -Encoding ASCII $jar = Join-Path $Dist 'rsx-loader.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-loader.jar ($((Get-Item $jar).Length) bytes)" Write-Host '' Write-Host ' Done:' -ForegroundColor Green Write-Host " $jar"