mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-01-05 21:54:15 +00:00
replace ${file.jarVersion} with something useful
This commit is contained in:
parent
7156e086f6
commit
13afad80fb
@ -267,6 +267,43 @@ void LocalModParseTask::processAsZip()
|
|||||||
|
|
||||||
m_result->details = ReadMCModTOML(file.readAll());
|
m_result->details = ReadMCModTOML(file.readAll());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
// to replace ${file.jarVersion} with the actual version, as needed
|
||||||
|
if (m_result->details && m_result->details->version == "${file.jarVersion}")
|
||||||
|
{
|
||||||
|
if (zip.setCurrentFile("META-INF/MANIFEST.MF"))
|
||||||
|
{
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
zip.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// quick and dirty line-by-line parser
|
||||||
|
auto manifestLines = file.readAll().split('\n');
|
||||||
|
QString manifestVersion = "";
|
||||||
|
for (auto &line : manifestLines)
|
||||||
|
{
|
||||||
|
if (QString(line).startsWith("Implementation-Version: "))
|
||||||
|
{
|
||||||
|
manifestVersion = QString(line).remove("Implementation-Version: ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
|
||||||
|
// also keep with forge's behavior of setting the version to "NONE" if none is found
|
||||||
|
if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "")
|
||||||
|
{
|
||||||
|
manifestVersion = "NONE";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_result->details->version = manifestVersion;
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zip.close();
|
zip.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user