Include Minecraft version and required Java runtime in paperclip jar manifests

This commit is contained in:
Jason Penilla 2024-06-18 15:09:12 -07:00
parent a5ae66c59a
commit 80ae37484a
No known key found for this signature in database
GPG key ID: 0E75A301420E48F8

View file

@ -109,11 +109,27 @@ abstract class CreateBundlerJar : ZippedTask() {
rootDir.resolve("META-INF/main-class").writeText(mainClass.get()) rootDir.resolve("META-INF/main-class").writeText(mainClass.get())
// copy version.json file // copy version.json file
vanillaBundlerJar.path.openZip().use { fs -> val versionJson = vanillaBundlerJar.path.openZip().use { fs ->
fs.getPath("/").resolve(FileEntry.VERSION_JSON).copyTo(rootDir.resolve("version.json")) val source = fs.getPath("/").resolve(FileEntry.VERSION_JSON)
source.copyTo(rootDir.resolve("version.json"))
source.bufferedReader().use {
gson.fromJson(it, VersionJson::class.java)
}
}
modifyManifest(rootDir.resolve("META-INF/MANIFEST.MF")) {
mainAttributes.putValue("Minecraft-Version", versionJson.name)
mainAttributes.putValue("Java-Runtime-Major-Version", versionJson.java_version)
} }
} }
data class VersionJson(
val id: String,
val name: String,
@Suppress("PropertyName")
val java_version: String,
)
private fun handleServerDependencies(rootDir: Path): List<FileEntry<ModuleId>> { private fun handleServerDependencies(rootDir: Path): List<FileEntry<ModuleId>> {
val libraries = mutableListOf<FileEntry<ModuleId>>() val libraries = mutableListOf<FileEntry<ModuleId>>()
val changedLibraries = mutableListOf<LibraryChange>() val changedLibraries = mutableListOf<LibraryChange>()