Added JavaPath function
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
82b15268bc
commit
ba990e075b
@ -48,7 +48,6 @@
|
|||||||
#include "net/PasteUpload.h"
|
#include "net/PasteUpload.h"
|
||||||
#include "pathmatcher/MultiMatcher.h"
|
#include "pathmatcher/MultiMatcher.h"
|
||||||
#include "pathmatcher/SimplePrefixMatcher.h"
|
#include "pathmatcher/SimplePrefixMatcher.h"
|
||||||
#include "settings/INIFile.h"
|
|
||||||
#include "ui/InstanceWindow.h"
|
#include "ui/InstanceWindow.h"
|
||||||
#include "ui/MainWindow.h"
|
#include "ui/MainWindow.h"
|
||||||
|
|
||||||
@ -106,8 +105,6 @@
|
|||||||
#include "icons/IconList.h"
|
#include "icons/IconList.h"
|
||||||
#include "net/HttpMetaCache.h"
|
#include "net/HttpMetaCache.h"
|
||||||
|
|
||||||
#include "java/JavaUtils.h"
|
|
||||||
|
|
||||||
#include "updater/ExternalUpdater.h"
|
#include "updater/ExternalUpdater.h"
|
||||||
|
|
||||||
#include "tools/JProfiler.h"
|
#include "tools/JProfiler.h"
|
||||||
@ -1833,3 +1830,7 @@ QUrl Application::normalizeImportUrl(QString const& url)
|
|||||||
return QUrl::fromUserInput(url);
|
return QUrl::fromUserInput(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const QString Application::javaPath()
|
||||||
|
{
|
||||||
|
return FS::PathCombine(m_dataPath, "java");
|
||||||
|
}
|
||||||
|
@ -162,6 +162,9 @@ class Application : public QApplication {
|
|||||||
/// the data path the application is using
|
/// the data path the application is using
|
||||||
const QString& dataRoot() { return m_dataPath; }
|
const QString& dataRoot() { return m_dataPath; }
|
||||||
|
|
||||||
|
/// the java installed path the application is using
|
||||||
|
const QString javaPath();
|
||||||
|
|
||||||
bool isPortable() { return m_portable; }
|
bool isPortable() { return m_portable; }
|
||||||
|
|
||||||
const Capabilities capabilities() { return m_capabilities; }
|
const Capabilities capabilities() { return m_capabilities; }
|
||||||
|
@ -337,6 +337,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
}
|
}
|
||||||
|
|
||||||
candidates.append(getMinecraftJavaBundle());
|
candidates.append(getMinecraftJavaBundle());
|
||||||
|
candidates.append(getPrismJavaBundle());
|
||||||
candidates = addJavasFromEnv(candidates);
|
candidates = addJavasFromEnv(candidates);
|
||||||
candidates.removeDuplicates();
|
candidates.removeDuplicates();
|
||||||
return candidates;
|
return candidates;
|
||||||
@ -363,6 +364,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java");
|
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java");
|
||||||
}
|
}
|
||||||
javas.append(getMinecraftJavaBundle());
|
javas.append(getMinecraftJavaBundle());
|
||||||
|
javas.append(getPrismJavaBundle());
|
||||||
javas = addJavasFromEnv(javas);
|
javas = addJavasFromEnv(javas);
|
||||||
javas.removeDuplicates();
|
javas.removeDuplicates();
|
||||||
return javas;
|
return javas;
|
||||||
@ -393,7 +395,6 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
scanJavaDir(snap + dirPath);
|
scanJavaDir(snap + dirPath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
scanJavaDir(FS::PathCombine(APPLICATION->dataRoot(), "java"));
|
|
||||||
// oracle RPMs
|
// oracle RPMs
|
||||||
scanJavaDirs("/usr/java");
|
scanJavaDirs("/usr/java");
|
||||||
// general locations used by distro packaging
|
// general locations used by distro packaging
|
||||||
@ -416,6 +417,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java"));
|
scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java"));
|
||||||
|
|
||||||
javas.append(getMinecraftJavaBundle());
|
javas.append(getMinecraftJavaBundle());
|
||||||
|
javas.append(getPrismJavaBundle());
|
||||||
javas = addJavasFromEnv(javas);
|
javas = addJavasFromEnv(javas);
|
||||||
javas.removeDuplicates();
|
javas.removeDuplicates();
|
||||||
return javas;
|
return javas;
|
||||||
@ -429,6 +431,8 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
javas.append(this->GetDefaultJava()->path);
|
javas.append(this->GetDefaultJava()->path);
|
||||||
|
|
||||||
javas.append(getMinecraftJavaBundle());
|
javas.append(getMinecraftJavaBundle());
|
||||||
|
javas.append(getPrismJavaBundle());
|
||||||
|
javas.removeDuplicates();
|
||||||
return addJavasFromEnv(javas);
|
return addJavasFromEnv(javas);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -484,3 +488,25 @@ QStringList getMinecraftJavaBundle()
|
|||||||
}
|
}
|
||||||
return javas;
|
return javas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList getPrismJavaBundle()
|
||||||
|
{
|
||||||
|
QList<QString> javas;
|
||||||
|
QDir dir(APPLICATION->javaPath());
|
||||||
|
if (!dir.exists())
|
||||||
|
return javas;
|
||||||
|
|
||||||
|
QString executable = "java";
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
executable += "w.exe";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
for (auto& entry : entries) {
|
||||||
|
QString prefix;
|
||||||
|
prefix = entry.canonicalFilePath();
|
||||||
|
javas.append(FS::PathCombine(prefix, "jre", "bin", executable));
|
||||||
|
javas.append(FS::PathCombine(prefix, "bin", executable));
|
||||||
|
}
|
||||||
|
return javas;
|
||||||
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
QString stripVariableEntries(QString name, QString target, QString remove);
|
QString stripVariableEntries(QString name, QString target, QString remove);
|
||||||
QProcessEnvironment CleanEnviroment();
|
QProcessEnvironment CleanEnviroment();
|
||||||
QStringList getMinecraftJavaBundle();
|
QStringList getMinecraftJavaBundle();
|
||||||
|
QStringList getPrismJavaBundle();
|
||||||
|
|
||||||
class JavaUtils : public QObject {
|
class JavaUtils : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -85,7 +85,7 @@ void Downloader::accept()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Task::Ptr task;
|
Task::Ptr task;
|
||||||
auto final_path = FS::PathCombine(APPLICATION->dataRoot(), "java", meta->vendor, meta->m_name);
|
auto final_path = FS::PathCombine(APPLICATION->javaPath(), meta->m_name);
|
||||||
switch (meta->downloadType) {
|
switch (meta->downloadType) {
|
||||||
case Java::DownloadType::Manifest:
|
case Java::DownloadType::Manifest:
|
||||||
task = makeShared<ManifestDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
task = makeShared<ManifestDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
||||||
|
Loading…
Reference in New Issue
Block a user