GH-2544 allow adding files to libraries
without affecting classpath
This is done by adding library-like objects into the `mavenFiles` list in version JSONs.
This commit is contained in:
parent
e6cc65cf69
commit
0281845fc8
@ -11,6 +11,7 @@ void LaunchProfile::clear()
|
||||
m_mainClass.clear();
|
||||
m_appletClass.clear();
|
||||
m_libraries.clear();
|
||||
m_mavenFiles.clear();
|
||||
m_traits.clear();
|
||||
m_jarMods.clear();
|
||||
m_mainJar.reset();
|
||||
@ -157,6 +158,22 @@ void LaunchProfile::applyLibrary(LibraryPtr library)
|
||||
}
|
||||
}
|
||||
|
||||
void LaunchProfile::applyMavenFile(LibraryPtr mavenFile)
|
||||
{
|
||||
if(!mavenFile->isActive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(mavenFile->isNative())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// unlike libraries, we do not keep only one version or try to dedupe them
|
||||
m_mavenFiles.append(Library::limitedCopy(mavenFile));
|
||||
}
|
||||
|
||||
const LibraryPtr LaunchProfile::getMainJar() const
|
||||
{
|
||||
return m_mainJar;
|
||||
@ -253,6 +270,11 @@ const QList<LibraryPtr> & LaunchProfile::getNativeLibraries() const
|
||||
return m_nativeLibraries;
|
||||
}
|
||||
|
||||
const QList<LibraryPtr> & LaunchProfile::getMavenFiles() const
|
||||
{
|
||||
return m_mavenFiles;
|
||||
}
|
||||
|
||||
void LaunchProfile::getLibraryFiles(
|
||||
const QString& architecture,
|
||||
QStringList& jars,
|
||||
|
@ -20,6 +20,7 @@ public: /* application of profile variables from patches */
|
||||
void applyJarMods(const QList<LibraryPtr> &jarMods);
|
||||
void applyMods(const QList<LibraryPtr> &jarMods);
|
||||
void applyLibrary(LibraryPtr library);
|
||||
void applyMavenFile(LibraryPtr library);
|
||||
void applyMainJar(LibraryPtr jar);
|
||||
void applyProblemSeverity(ProblemSeverity severity);
|
||||
/// clear the profile
|
||||
@ -37,6 +38,7 @@ public: /* getters for profile variables */
|
||||
const QList<LibraryPtr> & getJarMods() const;
|
||||
const QList<LibraryPtr> & getLibraries() const;
|
||||
const QList<LibraryPtr> & getNativeLibraries() const;
|
||||
const QList<LibraryPtr> & getMavenFiles() const;
|
||||
const LibraryPtr getMainJar() const;
|
||||
void getLibraryFiles(
|
||||
const QString & architecture,
|
||||
@ -79,10 +81,13 @@ private:
|
||||
/// the list of libraries
|
||||
QList<LibraryPtr> m_libraries;
|
||||
|
||||
/// the list of maven files to be placed in the libraries folder, but not acted upon
|
||||
QList<LibraryPtr> m_mavenFiles;
|
||||
|
||||
/// the main jar
|
||||
LibraryPtr m_mainJar;
|
||||
|
||||
/// the list of libraries
|
||||
/// the list of native libraries
|
||||
QList<LibraryPtr> m_nativeLibraries;
|
||||
|
||||
/// traits, collected from all the version files (version files can only add)
|
||||
|
@ -144,18 +144,14 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
}
|
||||
}
|
||||
|
||||
auto readLibs = [&](const char * which)
|
||||
auto readLibs = [&](const char * which, QList<LibraryPtr> & out)
|
||||
{
|
||||
for (auto libVal : requireArray(root.value(which)))
|
||||
{
|
||||
QJsonObject libObj = requireObject(libVal);
|
||||
// parse the library
|
||||
auto lib = libraryFromJson(libObj, filename);
|
||||
if(lib->rawName().artifactId() == "ForgeWrapper") {
|
||||
out->mainClass.clear();
|
||||
out->addProblem(ProblemSeverity::Error, QObject::tr("Forge workarounds have no place in MultiMC."));
|
||||
}
|
||||
out->libraries.append(lib);
|
||||
out.append(lib);
|
||||
}
|
||||
};
|
||||
bool hasPlusLibs = root.contains("+libraries");
|
||||
@ -164,16 +160,20 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
{
|
||||
out->addProblem(ProblemSeverity::Warning,
|
||||
QObject::tr("Version file has both '+libraries' and 'libraries'. This is no longer supported."));
|
||||
readLibs("libraries");
|
||||
readLibs("+libraries");
|
||||
readLibs("libraries", out->libraries);
|
||||
readLibs("+libraries", out->libraries);
|
||||
}
|
||||
else if (hasLibs)
|
||||
{
|
||||
readLibs("libraries");
|
||||
readLibs("libraries", out->libraries);
|
||||
}
|
||||
else if(hasPlusLibs)
|
||||
{
|
||||
readLibs("+libraries");
|
||||
readLibs("+libraries", out->libraries);
|
||||
}
|
||||
|
||||
if(root.contains("mavenFiles")) {
|
||||
readLibs("mavenFiles", out->mavenFiles);
|
||||
}
|
||||
|
||||
// if we have mainJar, just use it
|
||||
@ -280,6 +280,15 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
|
||||
}
|
||||
root.insert("libraries", array);
|
||||
}
|
||||
if (!patch->mavenFiles.isEmpty())
|
||||
{
|
||||
QJsonArray array;
|
||||
for (auto value: patch->mavenFiles)
|
||||
{
|
||||
array.append(OneSixVersionFormat::libraryToJson(value.get()));
|
||||
}
|
||||
root.insert("mavenFiles", array);
|
||||
}
|
||||
if (!patch->jarMods.isEmpty())
|
||||
{
|
||||
QJsonArray array;
|
||||
|
@ -41,6 +41,10 @@ void VersionFile::applyTo(LaunchProfile *profile)
|
||||
{
|
||||
profile->applyLibrary(library);
|
||||
}
|
||||
for (auto mavenFile : mavenFiles)
|
||||
{
|
||||
profile->applyMavenFile(mavenFile);
|
||||
}
|
||||
profile->applyProblemSeverity(getProblemSeverity());
|
||||
}
|
||||
|
||||
@ -53,4 +57,4 @@ void VersionFile::applyTo(LaunchProfile *profile)
|
||||
throw MinecraftVersionMismatch(uid, dependsOnMinecraftVersion, theirVersion);
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
@ -75,6 +75,9 @@ public: /* data */
|
||||
/// Mojang: list of libraries to add to the version
|
||||
QList<LibraryPtr> libraries;
|
||||
|
||||
/// MultiMC: list of maven files to put in the libraries folder, but not in classpath
|
||||
QList<LibraryPtr> mavenFiles;
|
||||
|
||||
/// The main jar (Minecraft version library, normally)
|
||||
LibraryPtr mainJar;
|
||||
|
||||
|
@ -45,6 +45,7 @@ void LibrariesTask::executeTask()
|
||||
QList<LibraryPtr> libArtifactPool;
|
||||
libArtifactPool.append(profile->getLibraries());
|
||||
libArtifactPool.append(profile->getNativeLibraries());
|
||||
libArtifactPool.append(profile->getMavenFiles());
|
||||
libArtifactPool.append(profile->getMainJar());
|
||||
processArtifactPool(libArtifactPool, failedLocalLibraries, inst->getLocalLibraryPath());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user