re-add option to specify a separate parchment game version
All checks were successful
Publish to snapshot maven / build (push) Successful in 23s

This commit is contained in:
moehreag 2024-10-28 15:13:50 +01:00
parent c2d6800981
commit d62987cda2
4 changed files with 26 additions and 9 deletions

View file

@ -7,7 +7,7 @@ plugins {
}
group = "dev.frogmc"
version = "0.0.1-alpha.28" + ("+local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
version = "0.0.1-alpha.29" + ("+local".takeUnless { project.hasProperty("FrogMCSnapshotsMavenPassword") } ?: "")
repositories {
maven {

View file

@ -72,12 +72,13 @@ class ProjectData(
var localCacheDir: Path?,
var minecraftVersion: String?,
var parchmentVersion: String?,
var parchmentGameVersion: String?,
var remappedGameJarPath: Path?,
var mappings: MappingBundle?,
var manifestUrl: String?,
var jarManifestProperties: MutableMap<String, String>
) {
internal constructor() : this(null,null, null, null, null, null, mutableMapOf())
internal constructor() : this(null,null, null, null, null, null, null, mutableMapOf())
}
class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
@ -86,6 +87,8 @@ class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
out.serializeNulls = true
out.name("local_cache_dir").value(value.localCacheDir?.absolutePathString())
out.name("minecraft_version").value(value.minecraftVersion)
out.name("parchment_version").value(value.parchmentVersion)
out.name("parchment_game_version").value(value.parchmentGameVersion)
out.name("remapped_game_jar_path").value(value.remappedGameJarPath?.absolutePathString())
out.name("mappings")
value.mappings?.let { MappingBundleTypeAdapter.write(out, it) } ?: out.nullValue()
@ -118,6 +121,10 @@ class ProjectDataTypeAdapter : TypeAdapter<ProjectData>() {
data.parchmentVersion = value
}
"parchment_game_version" -> {
data.parchmentGameVersion = value
}
"remapped_game_jar_path" -> {
data.remappedGameJarPath = Path.of(value)
}

View file

@ -1,6 +1,7 @@
package dev.frogmc.phytotelma.ext
import dev.frogmc.phytotelma.Constants
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
@ -13,9 +14,17 @@ abstract class MinecraftConfiguration @Inject constructor(
) {
val version: Property<String> = objects.property(String::class.java).unset()
val parchmentVersion: Property<String> = objects.property(String::class.java).unset()
val parchment: Property<ParchmentConfiguration> = objects.property(ParchmentConfiguration::class.java).convention(objects.newInstance(ParchmentConfiguration::class.java))
val manifestUrl: Property<String> = objects.property(String::class.java).convention(Constants.MOJANG_MANIFEST_URL)
fun parchment(action: Action<ParchmentConfiguration>) {
action.execute(parchment.get())
}
abstract class ParchmentConfiguration @Inject constructor(objects: ObjectFactory) {
val gameVersion: Property<String> = objects.property(String::class.java).unset()
val version: Property<String> = objects.property(String::class.java).unset()
}
}
abstract class VersionConfiguration @Inject constructor(objects: ObjectFactory) {

View file

@ -38,7 +38,7 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
error("No Minecraft version provided!")
}
val version = mcConf.version.get()
val parchmentVersion = mcConf.parchmentVersion.get()
val parchment = mcConf.parchment.get()
val projectData = ProjectStorage.get(project)
projectData.manifestUrl = mcConf.manifestUrl.get()
@ -54,7 +54,7 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
).reverse(),
ParchmentProvider.getParchment(
version,
projectData.localCacheDir!!.resolve("org/parchmentmc/parchment/${version}/${parchmentVersion}")
projectData.localCacheDir!!.resolve("org/parchmentmc/parchment/${parchment.gameVersion.get()}/${parchment.version.get()}")
)
)
)
@ -69,7 +69,7 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
remappedClientJar.createParentDirectories()
remappedServerJar.createParentDirectories()
val flattened = mappings.flattenData()
if (remappedClientJar.notExists() || parchmentVersion != projectData.parchmentVersion) {
if (remappedClientJar.notExists() || parchment.version.get() != projectData.parchmentVersion || parchment.gameVersion.get() != projectData.parchmentGameVersion) {
println("Remapping client...")
Thyroxine.remap(
flattened,
@ -77,7 +77,7 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
)
VersionChecker.saveClientPomFile(version, remappedClientJar.parent)
}
if (remappedServerJar.notExists() || parchmentVersion != projectData.parchmentVersion) {
if (remappedServerJar.notExists() || parchment.version.get() != projectData.parchmentVersion || parchment.gameVersion.get() != projectData.parchmentGameVersion) {
println("Remapping server...")
Thyroxine.remap(
flattened,
@ -89,8 +89,9 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
projectData.localCacheDir!!.resolve("net/minecraft/minecraft-merged/$version/minecraft-merged-$version.jar")
projectData.remappedGameJarPath = mergedJar
var applyAW = AccessWidener.needsUpdate(project)
if (mergedJar.notExists() || applyAW || parchmentVersion != projectData.parchmentVersion) {
projectData.parchmentVersion = parchmentVersion
if (mergedJar.notExists() || applyAW || parchment.version.get() != projectData.parchmentVersion || parchment.gameVersion.get() != projectData.parchmentGameVersion) {
projectData.parchmentVersion = parchment.version.get()
projectData.parchmentGameVersion = parchment.gameVersion.get()
println("Merging game...")
mergedJar.createParentDirectories()
FileSystems.newFileSystem(mergedJar, mapOf("create" to "true")).use { mergedFs ->