Make forge work.

Using classifiers FTW.
This commit is contained in:
Petr Mrázek 2014-07-19 23:16:02 +02:00
parent 8a56ab6780
commit c767707c95
20 changed files with 253 additions and 130 deletions

View File

@ -357,6 +357,9 @@ void MultiMC::initGlobalSettings()
m_settings->registerSetting("AutoUpdate", true);
m_settings->registerSetting("IconTheme", QString("multimc"));
// Minecraft Sneaky Updates
m_settings->registerSetting("AutoUpdateMinecraftVersions", true);
// Notifications
m_settings->registerSetting("ShownNotifications", QString());

View File

@ -29,10 +29,7 @@ class IconPickerDialog : public QDialog
public:
explicit IconPickerDialog(QWidget *parent = 0);
~IconPickerDialog();
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
int exec(QString selection);
#pragma clang diagnostic pop
QString selectedIconKey;
protected:

View File

@ -34,10 +34,7 @@ public:
void updateSize();
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
int exec(ProgressProvider *task);
#pragma clang diagnostic pop
void setSkipButton(bool present, QString label = QString());

View File

@ -365,6 +365,9 @@ void SettingsDialog::applySettings(SettingsObject *s)
}
s->set("JsonEditor", jsonEditor);
// Minecraft version updates
s->set("AutoUpdateMinecraftVersions", ui->autoupdateMinecraft->isChecked());
// Console
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
@ -470,6 +473,9 @@ void SettingsDialog::loadSettings(SettingsObject *s)
// Editors
ui->jsonEditorTextBox->setText(s->get("JsonEditor").toString());
// Minecraft version updates
ui->autoupdateMinecraft->setChecked(s->get("AutoUpdateMinecraftVersions").toBool());
// Console
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool());

View File

@ -409,6 +409,22 @@
<string>Minecraft</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Minecraft Version Updates</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QCheckBox" name="autoupdateMinecraft">
<property name="text">
<string>Automatically update to latest version revision</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="windowSizeGroupBox">
<property name="title">
@ -1056,11 +1072,30 @@
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>settingsTabs</tabstop>
<tabstop>autoUpdateCheckBox</tabstop>
<tabstop>updateChannelComboBox</tabstop>
<tabstop>trackFtbBox</tabstop>
<tabstop>ftbLauncherBox</tabstop>
<tabstop>ftbLauncherBrowseBtn</tabstop>
<tabstop>ftbBox</tabstop>
<tabstop>ftbBrowseBtn</tabstop>
<tabstop>instDirTextBox</tabstop>
<tabstop>instDirBrowseBtn</tabstop>
<tabstop>modsDirTextBox</tabstop>
<tabstop>modsDirBrowseBtn</tabstop>
<tabstop>lwjglDirTextBox</tabstop>
<tabstop>lwjglDirBrowseBtn</tabstop>
<tabstop>iconsDirTextBox</tabstop>
<tabstop>iconsDirBrowseBtn</tabstop>
<tabstop>languageBox</tabstop>
<tabstop>resetNotificationsBtn</tabstop>
<tabstop>sortLastLaunchedBtn</tabstop>
<tabstop>sortByNameBtn</tabstop>
<tabstop>themeComboBox</tabstop>
<tabstop>jsonEditorTextBox</tabstop>
<tabstop>jsonEditorBrowseBtn</tabstop>
<tabstop>autoupdateMinecraft</tabstop>
<tabstop>maximizedCheckBox</tabstop>
<tabstop>windowWidthSpinBox</tabstop>
<tabstop>windowHeightSpinBox</tabstop>
@ -1076,7 +1111,23 @@
<tabstop>jvmArgsTextBox</tabstop>
<tabstop>preLaunchCmdTextBox</tabstop>
<tabstop>postExitCmdTextBox</tabstop>
<tabstop>settingsTabs</tabstop>
<tabstop>proxyDefaultBtn</tabstop>
<tabstop>proxyNoneBtn</tabstop>
<tabstop>proxySOCKS5Btn</tabstop>
<tabstop>proxyHTTPBtn</tabstop>
<tabstop>proxyAddrEdit</tabstop>
<tabstop>proxyPortEdit</tabstop>
<tabstop>proxyUserEdit</tabstop>
<tabstop>proxyPassEdit</tabstop>
<tabstop>jprofilerPathEdit</tabstop>
<tabstop>jprofilerPathBtn</tabstop>
<tabstop>jprofilerCheckBtn</tabstop>
<tabstop>jvisualvmPathEdit</tabstop>
<tabstop>jvisualvmPathBtn</tabstop>
<tabstop>jvisualvmCheckBtn</tabstop>
<tabstop>mceditPathEdit</tabstop>
<tabstop>mceditPathBtn</tabstop>
<tabstop>mceditCheckBtn</tabstop>
</tabstops>
<resources>
<include location="../../graphics.qrc"/>

View File

@ -100,10 +100,7 @@ public:
/*!
* Sorts the version list.
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
virtual void sort() = 0;
#pragma clang diagnostic pop
protected
slots:

View File

@ -65,4 +65,8 @@ VersionFilterData::VersionFilterData()
* (these versions need to be tested by us first)
*/
legacyCutoffDate = timeFromS3Time("2013-06-25T15:08:56+02:00");
lwjglWhitelist =
QSet<QString>{"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
"net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
"org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
}

View File

@ -22,5 +22,7 @@ struct VersionFilterData
QSet<QString> legacyBlacklist;
// no new versions below this date will be accepted from Mojang servers
QDateTime legacyCutoffDate;
// Libraries that belong to LWJGL
QSet<QString> lwjglWhitelist;
};
extern VersionFilterData g_VersionFilterData;

View File

@ -133,8 +133,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
int sliding_insert_window = 0;
{
QJsonArray librariesPlus;
// A blacklist - we ignore these entirely
QSet<QString> blacklist{"lwjgl", "lwjgl_util", "lwjgl-platform"};
// A blacklist
QSet<QString> blacklist{"authlib", "realms"};
//
QList<QString> xzlist{"org.scala-lang", "com.typesafe"};
// for each library in the version we are adding (except for the blacklisted)
@ -143,15 +143,38 @@ bool ForgeInstaller::add(OneSixInstance *to)
QString libName = lib->name();
QString rawName = lib->rawName();
// ignore blacklisted stuff
// ignore lwjgl libraries.
if (g_VersionFilterData.lwjglWhitelist.contains(lib->fullname()))
continue;
// ignore other blacklisted (realms, authlib)
if (blacklist.contains(libName))
continue;
// WARNING: This could actually break.
// if this is the actual forge lib, set an absolute url for the download
if (libName.contains("minecraftforge"))
if(m_forge_version->type == ForgeVersion::Gradle)
{
lib->setAbsoluteUrl(m_universal_url);
if (libName == "forge")
{
lib->m_name.setClassifier("universal");
lib->finalize();
}
else if (libName == "minecraftforge")
{
QString forgeCoord ("net.minecraftforge:forge:%1:universal");
// using insane form of the MC version...
QString longVersion = m_forge_version->mcver + "-" + m_forge_version->jobbuildver;
GradleSpecifier spec(forgeCoord.arg(longVersion));
lib->m_name = spec;
lib->finalize();
}
}
else
{
if (libName.contains("minecraftforge"))
{
lib->setAbsoluteUrl(m_universal_url);
}
}
// WARNING: This could actually break.
@ -192,7 +215,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
{
// add lib
libObj.insert("insert", QString("prepend"));
if (lib->name() == "minecraftforge")
if (lib->name() == "minecraftforge" || lib->name() == "forge")
{
libObj.insert("MMC-depend", QString("hard"));
}

View File

@ -17,6 +17,13 @@ struct ForgeVersion : public BaseVersion
QString filename();
QString url();
enum
{
Invalid,
Legacy,
Gradle
} type = Invalid;
bool usesInstaller();
int m_buildnr = 0;

View File

@ -286,6 +286,7 @@ bool ForgeListLoadTask::parseForgeList(QList<BaseVersionPtr> &out)
fVersion->installer_filename = installer_filename;
fVersion->universal_filename = universal_filename;
fVersion->m_buildnr = build_nr;
fVersion->type = ForgeVersion::Legacy;
out.append(fVersion);
}
}
@ -335,6 +336,10 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
QJsonObject number = it.value().toObject();
std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
fVersion->m_buildnr = number.value("build").toDouble();
if(fVersion->m_buildnr >= 953 && fVersion->m_buildnr <= 965)
{
QLOG_DEBUG() << fVersion->m_buildnr;
}
fVersion->jobbuildver = number.value("version").toString();
fVersion->branch = number.value("branch").toString("");
fVersion->mcver = number.value("mcversion").toString();
@ -395,6 +400,7 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
}
fVersion->universal_filename = universal_filename;
fVersion->installer_filename = installer_filename;
fVersion->type = ForgeVersion::Gradle;
out.append(fVersion);
}
return true;

View File

@ -212,7 +212,7 @@ void LLListLoadTask::listDownloaded()
{
auto lib = RawLibrary::fromJson(libobject, "versions.json");
// hack to make liteloader 1.7.10_00 work
if(lib->m_name == "org.ow2.asm:asm-all:5.0.3")
if(lib->m_name == GradleSpecifier("org.ow2.asm:asm-all:5.0.3"))
{
lib->m_base_url = "http://repo.maven.apache.org/maven2/";
}

View File

@ -30,13 +30,13 @@ struct GradleSpecifier
QRegExp matcher("([^:@]+):([^:@]+):([^:@]+)" "(:([^:@]+))?" "(@([^:@]+))?");
m_valid = matcher.exactMatch(value);
auto elements = matcher.capturedTexts();
groupId = elements[1];
artifactId = elements[2];
version = elements[3];
classifier = elements[5];
m_groupId = elements[1];
m_artifactId = elements[2];
m_version = elements[3];
m_classifier = elements[5];
if(!elements[7].isEmpty())
{
extension = elements[7];
m_extension = elements[7];
}
return *this;
}
@ -44,14 +44,14 @@ struct GradleSpecifier
{
if(!m_valid)
return "INVALID";
QString retval = groupId + ":" + artifactId + ":" + version;
if(!classifier.isEmpty())
QString retval = m_groupId + ":" + m_artifactId + ":" + m_version;
if(!m_classifier.isEmpty())
{
retval += ":" + classifier;
retval += ":" + m_classifier;
}
if(extension.isExplicit())
if(m_extension.isExplicit())
{
retval += "@" + extension;
retval += "@" + m_extension;
}
return retval;
}
@ -59,25 +59,71 @@ struct GradleSpecifier
{
if(!m_valid)
return "INVALID";
QString path = groupId;
QString path = m_groupId;
path.replace('.', '/');
path += '/' + artifactId + '/' + version + '/' + artifactId + '-' + version;
if(!classifier.isEmpty())
path += '/' + m_artifactId + '/' + m_version + '/' + m_artifactId + '-' + m_version;
if(!m_classifier.isEmpty())
{
path += "-" + classifier;
path += "-" + m_classifier;
}
path += "." + extension;
path += "." + m_extension;
return path;
}
bool valid()
inline bool valid() const
{
return m_valid;
}
inline QString version() const
{
return m_version;
}
inline QString groupId() const
{
return m_groupId;
}
inline QString artifactId() const
{
return m_artifactId;
}
inline void setClassifier(const QString & classifier)
{
m_classifier = classifier;
}
inline QString classifier() const
{
return m_classifier;
}
inline QString extension() const
{
return m_extension;
}
inline QString artifactPrefix() const
{
return m_groupId + ":" + m_artifactId;
}
bool matchName(const GradleSpecifier & other)
{
return other.artifactId() == artifactId() && other.groupId() == groupId();
}
bool operator==(const GradleSpecifier & other)
{
if(m_groupId != other.m_groupId)
return false;
if(m_artifactId != other.m_artifactId)
return false;
if(m_version != other.m_version)
return false;
if(m_classifier != other.m_classifier)
return false;
if(m_extension != other.m_extension)
return false;
return true;
}
private:
QString groupId;
QString artifactId;
QString version;
QString classifier;
DefaultVariable<QString> extension = DefaultVariable<QString>("jar");
QString m_groupId;
QString m_artifactId;
QString m_version;
QString m_classifier;
DefaultVariable<QString> m_extension = DefaultVariable<QString>("jar");
bool m_valid = false;
};

View File

@ -2,6 +2,8 @@
#include "InstanceVersion.h"
#include "VersionBuildError.h"
#include "VersionBuilder.h"
#include "MultiMC.h"
#include "logic/settings/SettingsObject.h"
bool MinecraftVersion::usesLegacyLauncher()
{
@ -141,3 +143,15 @@ QString MinecraftVersion::getPatchFilename()
{
return QString();
}
bool MinecraftVersion::needsUpdate()
{
auto settings = MMC->settings();
bool result = hasUpdate() && settings->get("AutoUpdateMinecraftVersions").toBool();
return result;
}
bool MinecraftVersion::hasUpdate()
{
return m_versionSource == Remote || (m_versionSource == Local && upstreamUpdate);
}

View File

@ -45,14 +45,8 @@ public: /* methods */
virtual QString getPatchVersion() override;
virtual QString getPatchName() override;
virtual QString getPatchFilename() override;
bool needsUpdate()
{
return m_versionSource == Remote;
}
bool hasUpdate()
{
return m_versionSource == Remote || (m_versionSource == Local && upstreamUpdate);
}
bool needsUpdate();
bool hasUpdate();
private: /* methods */
void applyFileTo(InstanceVersion *version);

View File

@ -266,7 +266,8 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s
QString versionTypeStr = versionObj.value("type").toString("");
if (versionTypeStr.isEmpty())
{
// FIXME: log this somewhere
QLOG_ERROR() << "Ignoring" << versionID
<< "because it doesn't have the version type set.";
continue;
}
// OneSix or Legacy. use filter to determine type
@ -284,10 +285,13 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s
}
else
{
// FIXME: log this somewhere
QLOG_ERROR() << "Ignoring" << versionID
<< "because it has an invalid version type.";
continue;
}
mcVersion->m_type = versionTypeStr;
QLOG_INFO() << "Loaded version" << versionID << "from"
<< ((source == Remote) ? "remote" : "local") << "version list.";
tempList.append(mcVersion);
}
updateListData(tempList);
@ -333,12 +337,6 @@ void MinecraftVersionList::updateListData(QList<BaseVersionPtr> versions)
{
continue;
}
// is it actually an update?
if (orig->m_updateTime >= added->m_updateTime)
{
// nope.
continue;
}
// alright, it's an update. put it inside the original, for further processing.
orig->upstreamUpdate = added;
}
@ -451,13 +449,10 @@ void MCVListVersionUpdateTask::json_downloaded()
}
QList<RawLibraryPtr> filteredLibs;
QList<RawLibraryPtr> lwjglLibs;
QSet<QString> lwjglFilter = {
"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
"net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
"org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
for (auto lib : file->overwriteLibs)
{
if (lwjglFilter.contains(lib->fullname()))
if (g_VersionFilterData.lwjglWhitelist.contains(lib->fullname()))
{
lwjglLibs.append(lib);
}
@ -581,9 +576,11 @@ void MinecraftVersionList::finalizeUpdate(QString version)
auto updatedVersion = std::dynamic_pointer_cast<MinecraftVersion>(m_vlist[idx]);
// reject any updates to builtin versions.
if (updatedVersion->m_versionSource == Builtin)
return;
// if we have an update for the version, replace it, make the update local
if (updatedVersion->upstreamUpdate)
{
auto updatedWith = updatedVersion->upstreamUpdate;
@ -593,6 +590,7 @@ void MinecraftVersionList::finalizeUpdate(QString version)
}
else
{
// otherwise, just set the version as local;
updatedVersion->m_versionSource = Local;
}

View File

@ -30,7 +30,7 @@ OneSixLibrary::OneSixLibrary(RawLibraryPtr base)
m_hint = base->m_hint;
m_absolute_url = base->m_absolute_url;
extract_excludes = base->extract_excludes;
m_native_suffixes = base->m_native_suffixes;
m_native_classifiers = base->m_native_classifiers;
m_rules = base->m_rules;
finalize();
}
@ -42,34 +42,8 @@ OneSixLibraryPtr OneSixLibrary::fromRawLibrary(RawLibraryPtr lib)
void OneSixLibrary::finalize()
{
QStringList parts = m_name.split(':');
QString relative = parts[0];
relative.replace('.', '/');
relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2];
if (!isNative())
relative += ".jar";
else
{
if (m_native_suffixes.contains(currentSystem))
{
relative += "-" + m_native_suffixes[currentSystem] + ".jar";
}
else
{
// really, bad.
relative += ".jar";
}
}
m_decentname = parts[1];
m_decentversion = minVersion = parts[2];
m_storage_path = relative;
if(m_base_url.isEmpty())
m_download_url = QString("https://" + URLConstants::LIBRARY_BASE) + relative;
else
m_download_url = m_base_url + relative;
QString relative;
if (m_rules.empty())
{
m_is_active = true;
@ -87,13 +61,32 @@ void OneSixLibrary::finalize()
}
if (isNative())
{
m_is_active = m_is_active && m_native_suffixes.contains(currentSystem);
GradleSpecifier nativeSpec = m_name;
m_is_active = m_is_active && m_native_classifiers.contains(currentSystem);
m_decenttype = "Native";
if(m_native_classifiers.contains(currentSystem))
{
nativeSpec.setClassifier(m_native_classifiers[currentSystem]);
}
else
{
nativeSpec.setClassifier("INVALID");
}
relative = nativeSpec.toPath();
}
else
{
relative = m_name.toPath();
m_decenttype = "Java";
}
m_decentname = m_name.artifactId();
m_decentversion = minVersion = m_name.version();
m_storage_path = relative;
if(m_base_url.isEmpty())
m_download_url = QString("https://" + URLConstants::LIBRARY_BASE) + relative;
else
m_download_url = m_base_url + relative;
}
void OneSixLibrary::setName(const QString &name)
@ -106,11 +99,11 @@ void OneSixLibrary::setBaseUrl(const QString &base_url)
}
void OneSixLibrary::addNative(OpSys os, const QString &suffix)
{
m_native_suffixes[os] = suffix;
m_native_classifiers[os] = suffix;
}
void OneSixLibrary::clearSuffixes()
{
m_native_suffixes.clear();
m_native_classifiers.clear();
}
void OneSixLibrary::setRules(QList<std::shared_ptr<Rule>> rules)
{

View File

@ -54,7 +54,7 @@ RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &fil
OpSys opSys = OpSys_fromString(it.key());
if (opSys != Os_Other)
{
out->m_native_suffixes[opSys] = it.value().toString();
out->m_native_classifiers[opSys] = it.value().toString();
}
}
}
@ -134,13 +134,13 @@ RawLibraryPtr RawLibrary::fromJsonPlus(const QJsonObject &libObj, const QString
bool RawLibrary::isNative() const
{
return m_native_suffixes.size() != 0;
return m_native_classifiers.size() != 0;
}
QJsonObject RawLibrary::toJson()
{
QJsonObject libRoot;
libRoot.insert("name", m_name);
libRoot.insert("name", (QString)m_name);
if (m_absolute_url.size())
libRoot.insert("MMC-absoluteUrl", m_absolute_url);
if (m_hint.size())
@ -154,8 +154,8 @@ QJsonObject RawLibrary::toJson()
if (isNative())
{
QJsonObject nativeList;
auto iter = m_native_suffixes.begin();
while (iter != m_native_suffixes.end())
auto iter = m_native_classifiers.begin();
while (iter != m_native_classifiers.end())
{
nativeList.insert(OpSys_toString(iter.key()), iter.value());
iter++;
@ -188,18 +188,5 @@ QJsonObject RawLibrary::toJson()
QString RawLibrary::fullname()
{
QStringList parts = m_name.split(':');
return parts[0] + ":" + parts[1];
}
QString RawLibrary::group()
{
QStringList parts = m_name.split(':');
return parts[0];
}
QString RawLibrary::version()
{
QStringList parts = m_name.split(':');
return parts[2];
return m_name.artifactPrefix();
}

View File

@ -8,6 +8,7 @@
#include "logic/minecraft/OneSixRule.h"
#include "logic/minecraft/OpSys.h"
#include "GradleSpecifier.h"
#include "logic/net/URLConstants.h"
class RawLibrary;
@ -23,11 +24,9 @@ public: /* methods */
QJsonObject toJson();
QString fullname();
QString version();
QString group();
public: /* data */
QString m_name;
GradleSpecifier m_name;
QString m_base_url;
/// type hint - modifies how the library is treated
@ -41,7 +40,7 @@ public: /* data */
/// Returns true if the library is native
bool isNative() const;
/// native suffixes per OS
QMap<OpSys, QString> m_native_suffixes;
QMap<OpSys, QString> m_native_classifiers;
bool applyRules = false;
QList<std::shared_ptr<Rule>> m_rules;

View File

@ -17,13 +17,13 @@ using namespace MMCJson;
#define CURRENT_MINIMUM_LAUNCHER_VERSION 14
int findLibrary(QList<OneSixLibraryPtr> haystack, const QString &needle)
int findLibraryByName(QList<OneSixLibraryPtr> haystack, const GradleSpecifier &needle)
{
int retval = -1;
for (int i = 0; i < haystack.size(); ++i)
{
QString chunk = haystack.at(i)->rawName();
if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix).indexIn(chunk) != -1)
if(haystack.at(i)->m_name.matchName(needle))
{
// only one is allowed.
if (retval != -1)
@ -382,7 +382,7 @@ void VersionFile::applyTo(InstanceVersion *version)
case RawLibrary::Apply:
{
// QLOG_INFO() << "Applying lib " << lib->name;
int index = findLibrary(version->libraries, lib->m_name);
int index = findLibraryByName(version->libraries, lib->m_name);
if (index >= 0)
{
auto library = version->libraries[index];
@ -405,7 +405,7 @@ void VersionFile::applyTo(InstanceVersion *version)
if (lib->isNative())
{
// library->clearSuffixes();
library->m_native_suffixes = lib->m_native_suffixes;
library->m_native_classifiers = lib->m_native_classifiers;
/*
for (auto native : lib->natives)
{
@ -429,9 +429,7 @@ void VersionFile::applyTo(InstanceVersion *version)
case RawLibrary::Prepend:
{
// QLOG_INFO() << "Adding lib " << lib->name;
const int startOfVersion = lib->m_name.lastIndexOf(':') + 1;
const int index = findLibrary(
version->libraries, QString(lib->m_name).replace(startOfVersion, INT_MAX, '*'));
const int index = findLibraryByName(version->libraries, lib->m_name);
if (index < 0)
{
if (lib->insertType == RawLibrary::Append)
@ -446,8 +444,8 @@ void VersionFile::applyTo(InstanceVersion *version)
else
{
auto otherLib = version->libraries.at(index);
const Util::Version ourVersion = lib->m_name.mid(startOfVersion, INT_MAX);
const Util::Version otherVersion = otherLib->version();
const Util::Version ourVersion = lib->m_name.version();
const Util::Version otherVersion = otherLib->m_name.version();
// if the existing version is a hard dependency we can either use it or
// fail, but we can't change it
if (otherLib->dependType == OneSixLibrary::Hard)
@ -497,16 +495,17 @@ void VersionFile::applyTo(InstanceVersion *version)
}
case RawLibrary::Replace:
{
QString toReplace;
GradleSpecifier toReplace;
if (lib->insertData.isEmpty())
{
const int startOfVersion = lib->m_name.lastIndexOf(':') + 1;
toReplace = QString(lib->m_name).replace(startOfVersion, INT_MAX, '*');
toReplace = lib->m_name;
}
else
{
toReplace = lib->insertData;
}
// QLOG_INFO() << "Replacing lib " << toReplace << " with " << lib->name;
int index = findLibrary(version->libraries, toReplace);
int index = findLibraryByName(version->libraries, toReplace);
if (index >= 0)
{
version->libraries.replace(index, OneSixLibrary::fromRawLibrary(lib));
@ -521,7 +520,7 @@ void VersionFile::applyTo(InstanceVersion *version)
}
for (auto lib : removeLibs)
{
int index = findLibrary(version->libraries, lib);
int index = findLibraryByName(version->libraries, lib);
if (index >= 0)
{
// QLOG_INFO() << "Removing lib " << lib;