NOISSUE remove OneSixLibrary

This commit is contained in:
Petr Mrázek 2016-02-26 02:04:21 +01:00
parent f6b2ccb110
commit 71e4b147ec
13 changed files with 55 additions and 134 deletions

View File

@ -181,8 +181,6 @@ set(LOGIC_SOURCES
minecraft/MinecraftVersionList.cpp minecraft/MinecraftVersionList.cpp
minecraft/MinecraftVersionList.h minecraft/MinecraftVersionList.h
minecraft/NullProfileStrategy.h minecraft/NullProfileStrategy.h
minecraft/OneSixLibrary.cpp
minecraft/OneSixLibrary.h
minecraft/OneSixProfileStrategy.cpp minecraft/OneSixProfileStrategy.cpp
minecraft/OneSixProfileStrategy.h minecraft/OneSixProfileStrategy.h
minecraft/OneSixRule.cpp minecraft/OneSixRule.cpp

View File

@ -15,7 +15,7 @@
#include "ForgeInstaller.h" #include "ForgeInstaller.h"
#include "minecraft/MinecraftProfile.h" #include "minecraft/MinecraftProfile.h"
#include "minecraft/OneSixLibrary.h" #include "minecraft/GradleSpecifier.h"
#include "net/HttpMetaCache.h" #include "net/HttpMetaCache.h"
#include "tasks/Task.h" #include "tasks/Task.h"
#include "minecraft/OneSixInstance.h" #include "minecraft/OneSixInstance.h"
@ -86,10 +86,10 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr
m_forgeVersionString = installObj.value("version").toString().remove("Forge").trimmed(); m_forgeVersionString = installObj.value("version").toString().remove("Forge").trimmed();
// where do we put the library? decode the mojang path // where do we put the library? decode the mojang path
OneSixLibrary lib(libraryName); GradleSpecifier lib(libraryName);
auto cacheentry = ENV.metacache()->resolveEntry("libraries", lib.storageSuffix()); auto cacheentry = ENV.metacache()->resolveEntry("libraries", lib.toPath());
finalPath = "libraries/" + lib.storageSuffix(); finalPath = "libraries/" + lib.toPath();
if (!FS::ensureFilePathExists(finalPath)) if (!FS::ensureFilePathExists(finalPath))
return; return;

View File

@ -2,7 +2,7 @@
#include "FTBProfileStrategy.h" #include "FTBProfileStrategy.h"
#include "minecraft/MinecraftProfile.h" #include "minecraft/MinecraftProfile.h"
#include "minecraft/OneSixLibrary.h" #include "minecraft/GradleSpecifier.h"
#include "tasks/SequentialTask.h" #include "tasks/SequentialTask.h"
#include "forge/ForgeInstaller.h" #include "forge/ForgeInstaller.h"
#include "forge/ForgeVersionList.h" #include "forge/ForgeVersionList.h"
@ -77,8 +77,8 @@ void OneSixFTBInstance::copy(const QDir &newDir)
qDebug() << "Copying FTB libraries"; qDebug() << "Copying FTB libraries";
for (auto library : libraryNames) for (auto library : libraryNames)
{ {
OneSixLibrary lib(library); GradleSpecifier lib(library);
const QString out = QDir::current().absoluteFilePath("libraries/" + lib.storageSuffix()); const QString out = QDir::current().absoluteFilePath("libraries/" + lib.toPath());
if (QFile::exists(out)) if (QFile::exists(out))
{ {
continue; continue;
@ -87,9 +87,9 @@ void OneSixFTBInstance::copy(const QDir &newDir)
{ {
qCritical() << "Couldn't create folder structure for" << out; qCritical() << "Couldn't create folder structure for" << out;
} }
if (!QFile::copy(librariesPath().absoluteFilePath(lib.storageSuffix()), out)) if (!QFile::copy(librariesPath().absoluteFilePath(lib.toPath()), out))
{ {
qCritical() << "Couldn't copy" << lib.rawName(); qCritical() << "Couldn't copy" << QString(lib);
} }
} }
} }

View File

@ -2,8 +2,6 @@
#include "minecraft/OneSixInstance.h" #include "minecraft/OneSixInstance.h"
class OneSixLibrary;
class OneSixFTBInstance : public OneSixInstance class OneSixFTBInstance : public OneSixInstance
{ {
Q_OBJECT Q_OBJECT

View File

@ -21,7 +21,7 @@
#include <QDebug> #include <QDebug>
#include "minecraft/MinecraftProfile.h" #include "minecraft/MinecraftProfile.h"
#include "minecraft/OneSixLibrary.h" #include "minecraft/RawLibrary.h"
#include "minecraft/OneSixInstance.h" #include "minecraft/OneSixInstance.h"
#include "liteloader/LiteLoaderVersionList.h" #include "liteloader/LiteLoaderVersionList.h"
#include "Exception.h" #include "Exception.h"
@ -51,19 +51,14 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
for (auto rawLibrary : m_version->libraries) for (auto rawLibrary : m_version->libraries)
{ {
OneSixLibrary lib(rawLibrary); libraries.append(rawLibrary->toJson());
libraries.append(lib.toJson());
} }
// liteloader // liteloader
{ {
OneSixLibrary liteloaderLib("com.mumfrey:liteloader:" + m_version->version); RawLibrary liteloaderLib("com.mumfrey:liteloader:" + m_version->version);
liteloaderLib.setAbsoluteUrl( liteloaderLib.setAbsoluteUrl(QString("http://dl.liteloader.com/versions/com/mumfrey/liteloader/%1/%2").arg(m_version->mcVersion, m_version->file));
QString("http://dl.liteloader.com/versions/com/mumfrey/liteloader/%1/%2")
.arg(m_version->mcVersion, m_version->file));
QJsonObject llLibObj = liteloaderLib.toJson(); QJsonObject llLibObj = liteloaderLib.toJson();
llLibObj.insert("insert", QString("prepend"));
llLibObj.insert("MMC-depend", QString("hard"));
libraries.append(llLibObj); libraries.append(llLibObj);
} }

View File

@ -233,9 +233,9 @@ bool MinecraftProfile::revertToVanilla()
return true; return true;
} }
QList<std::shared_ptr<OneSixLibrary> > MinecraftProfile::getActiveNormalLibs() QList<std::shared_ptr<RawLibrary> > MinecraftProfile::getActiveNormalLibs()
{ {
QList<std::shared_ptr<OneSixLibrary> > output; QList<std::shared_ptr<RawLibrary> > output;
for (auto lib : libraries) for (auto lib : libraries)
{ {
if (lib->isActive() && !lib->isNative()) if (lib->isActive() && !lib->isNative())
@ -254,9 +254,9 @@ QList<std::shared_ptr<OneSixLibrary> > MinecraftProfile::getActiveNormalLibs()
return output; return output;
} }
QList<std::shared_ptr<OneSixLibrary> > MinecraftProfile::getActiveNativeLibs() QList<std::shared_ptr<RawLibrary> > MinecraftProfile::getActiveNativeLibs()
{ {
QList<std::shared_ptr<OneSixLibrary> > output; QList<std::shared_ptr<RawLibrary> > output;
for (auto lib : libraries) for (auto lib : libraries)
{ {
if (lib->isActive() && lib->isNative()) if (lib->isActive() && lib->isNative())

View File

@ -21,7 +21,7 @@
#include <QList> #include <QList>
#include <memory> #include <memory>
#include "OneSixLibrary.h" #include "RawLibrary.h"
#include "VersionFile.h" #include "VersionFile.h"
#include "JarMod.h" #include "JarMod.h"
@ -96,10 +96,10 @@ public:
public: public:
/// get all java libraries that belong to the classpath /// get all java libraries that belong to the classpath
QList<std::shared_ptr<OneSixLibrary>> getActiveNormalLibs(); QList<RawLibraryPtr> getActiveNormalLibs();
/// get all native libraries that need to be available to the process /// get all native libraries that need to be available to the process
QList<std::shared_ptr<OneSixLibrary>> getActiveNativeLibs(); QList<RawLibraryPtr> getActiveNativeLibs();
/// get file ID of the patch file at # /// get file ID of the patch file at #
QString versionFileId(const int index) const; QString versionFileId(const int index) const;
@ -171,10 +171,10 @@ public: /* data */
QString appletClass; QString appletClass;
/// the list of libs - both active and inactive, native and java /// the list of libs - both active and inactive, native and java
QList<OneSixLibraryPtr> libraries; QList<RawLibraryPtr> libraries;
/// same, but only vanilla. /// same, but only vanilla.
QList<OneSixLibraryPtr> vanillaLibraries; QList<RawLibraryPtr> vanillaLibraries;
/// traits, collected from all the version files (version files can only add) /// traits, collected from all the version files (version files can only add)
QSet<QString> traits; QSet<QString> traits;

View File

@ -1,42 +0,0 @@
/* Copyright 2013-2015 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <QJsonArray>
#include "OneSixLibrary.h"
#include "OneSixRule.h"
#include "OpSys.h"
OneSixLibrary::OneSixLibrary(RawLibraryPtr base)
{
m_name = base->m_name;
m_base_url = base->m_base_url;
m_hint = base->m_hint;
m_absolute_url = base->m_absolute_url;
extract_excludes = base->extract_excludes;
m_native_classifiers = base->m_native_classifiers;
m_rules = base->m_rules;
m_storagePrefix = base->m_storagePrefix;
// these only make sense for raw libraries. OneSix
/*
insertType = base->insertType;
insertData = base->insertData;
*/
}
OneSixLibraryPtr OneSixLibrary::fromRawLibrary(RawLibraryPtr lib)
{
return OneSixLibraryPtr(new OneSixLibrary(lib));
}

View File

@ -1,50 +0,0 @@
/* Copyright 2013-2015 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <QString>
#include <QStringList>
#include <QMap>
#include <QJsonObject>
#include <QDir>
#include <memory>
#include "net/URLConstants.h"
#include "minecraft/OpSys.h"
#include "minecraft/RawLibrary.h"
class OneSixLibrary;
typedef std::shared_ptr<OneSixLibrary> OneSixLibraryPtr;
/**
* This is a leftover from a previous design.
* All it does is separate the 'Raw' libraries read from files from the 'OneSix' libraries
* used for actually doing things.
*
* DEPRECATED, but still useful to keep the data clean and separated by type.
*/
class OneSixLibrary : public RawLibrary
{
public:
/// Constructor
OneSixLibrary(const QString &name)
{
m_name = name;
}
/// Constructor
OneSixLibrary(RawLibraryPtr base);
static OneSixLibraryPtr fromRawLibrary(RawLibraryPtr lib);
};

View File

@ -27,7 +27,7 @@
#include "BaseInstance.h" #include "BaseInstance.h"
#include "minecraft/MinecraftVersionList.h" #include "minecraft/MinecraftVersionList.h"
#include "minecraft/MinecraftProfile.h" #include "minecraft/MinecraftProfile.h"
#include "minecraft/OneSixLibrary.h" #include "minecraft/RawLibrary.h"
#include "minecraft/OneSixInstance.h" #include "minecraft/OneSixInstance.h"
#include "forge/ForgeMirrors.h" #include "forge/ForgeMirrors.h"
#include "net/URLConstants.h" #include "net/URLConstants.h"
@ -213,7 +213,7 @@ void OneSixUpdate::jarlibStart()
auto metacache = ENV.metacache(); auto metacache = ENV.metacache();
QList<ForgeXzDownloadPtr> ForgeLibs; QList<ForgeXzDownloadPtr> ForgeLibs;
QList<std::shared_ptr<OneSixLibrary>> brokenLocalLibs; QList<RawLibraryPtr> brokenLocalLibs;
for (auto lib : libs) for (auto lib : libs)
{ {

View File

@ -18,14 +18,36 @@ typedef std::shared_ptr<RawLibrary> RawLibraryPtr;
class RawLibrary class RawLibrary
{ {
friend class OneSixLibrary; public:
public: /* methods */ RawLibrary()
{
}
RawLibrary(const QString &name)
{
m_name = name;
}
/// limited copy without some data. TODO: why?
static RawLibraryPtr limitedCopy(RawLibraryPtr base)
{
auto newlib = std::make_shared<RawLibrary>();
newlib->m_name = base->m_name;
newlib->m_base_url = base->m_base_url;
newlib->m_hint = base->m_hint;
newlib->m_absolute_url = base->m_absolute_url;
newlib->extract_excludes = base->extract_excludes;
newlib->m_native_classifiers = base->m_native_classifiers;
newlib->m_rules = base->m_rules;
newlib->m_storagePrefix = base->m_storagePrefix;
return newlib;
}
/// read and create a basic library /// read and create a basic library
static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename); static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename);
/// Convert the library back to an JSON object /// Convert the library back to an JSON object
QJsonObject toJson() const; QJsonObject toJson() const;
public: /* methods */
/// Returns the raw name field /// Returns the raw name field
const GradleSpecifier & rawName() const const GradleSpecifier & rawName() const
{ {

View File

@ -4,7 +4,7 @@
#include <QDebug> #include <QDebug>
#include "minecraft/VersionFile.h" #include "minecraft/VersionFile.h"
#include "minecraft/OneSixLibrary.h" #include "minecraft/RawLibrary.h"
#include "minecraft/MinecraftProfile.h" #include "minecraft/MinecraftProfile.h"
#include "minecraft/JarMod.h" #include "minecraft/JarMod.h"
#include "ParseUtils.h" #include "ParseUtils.h"
@ -32,7 +32,7 @@ static QString readStringRet(const QJsonObject &root, const QString &key)
return QString(); return QString();
} }
int findLibraryByName(QList<OneSixLibraryPtr> haystack, const GradleSpecifier &needle) int findLibraryByName(QList<RawLibraryPtr> haystack, const GradleSpecifier &needle)
{ {
int retval = -1; int retval = -1;
for (int i = 0; i < haystack.size(); ++i) for (int i = 0; i < haystack.size(); ++i)
@ -379,10 +379,10 @@ void VersionFile::applyTo(MinecraftProfile *version)
version->traits.unite(traits); version->traits.unite(traits);
if (shouldOverwriteLibs) if (shouldOverwriteLibs)
{ {
QList<OneSixLibraryPtr> libs; QList<RawLibraryPtr> libs;
for (auto lib : overwriteLibs) for (auto lib : overwriteLibs)
{ {
libs.append(OneSixLibrary::fromRawLibrary(lib)); libs.append(RawLibrary::limitedCopy(lib));
} }
if (isMinecraftVersion()) if (isMinecraftVersion())
{ {
@ -397,14 +397,14 @@ void VersionFile::applyTo(MinecraftProfile *version)
// library not found? just add it. // library not found? just add it.
if (index < 0) if (index < 0)
{ {
version->libraries.append(OneSixLibrary::fromRawLibrary(addedLibrary)); version->libraries.append(RawLibrary::limitedCopy(addedLibrary));
continue; continue;
} }
auto existingLibrary = version->libraries.at(index); auto existingLibrary = version->libraries.at(index);
// if we are higher it means we should update // if we are higher it means we should update
if (Version(addedLibrary->version()) > Version(existingLibrary->version())) if (Version(addedLibrary->version()) > Version(existingLibrary->version()))
{ {
auto library = OneSixLibrary::fromRawLibrary(addedLibrary); auto library = RawLibrary::limitedCopy(addedLibrary);
version->libraries.replace(index, library); version->libraries.replace(index, library);
} }
} }

View File

@ -9,7 +9,7 @@
#include "minecraft/OpSys.h" #include "minecraft/OpSys.h"
#include "minecraft/OneSixRule.h" #include "minecraft/OneSixRule.h"
#include "ProfilePatch.h" #include "ProfilePatch.h"
#include "OneSixLibrary.h" #include "RawLibrary.h"
#include "JarMod.h" #include "JarMod.h"
class MinecraftProfile; class MinecraftProfile;