logic: add auto-detection for JRE System Library

* fixed error columns are not saved to database correctly
* implemented setting JRE System Library paths in app settings
* added detector for JRE System Library that not use Java Runtime specified in AppSettings but detects JRE on its own by reusing the JavaPathDetector.
* added option to use JRE System Library in JavaSourceGroup
This commit is contained in:
malte_langkabel
2017-07-10 18:12:52 +02:00
parent b4166be89b
commit 9bcde198a5
23 changed files with 404 additions and 99 deletions
@@ -0,0 +1,35 @@
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h"
#include "utility/path_detector/java_runtime/JavaPathDetector.h"
#include "settings/ApplicationSettings.h"
#include "utility/file/FilePath.h"
#include "utility/file/FileSystem.h"
JreSystemLibraryPathDetector::JreSystemLibraryPathDetector(std::shared_ptr<JavaPathDetector> javaPathDetector)
: PathDetector("JRE System Library")
, m_javaPathDetector(javaPathDetector)
{
}
JreSystemLibraryPathDetector::~JreSystemLibraryPathDetector()
{
}
std::vector<FilePath> JreSystemLibraryPathDetector::getPaths() const
{
std::vector<FilePath> paths;
for (const FilePath& jrePath: m_javaPathDetector->getPaths())
{
const FilePath javaRoot = jrePath.parentDirectory().parentDirectory().parentDirectory();
for (const FilePath& jarPath : FileSystem::getFilePathsFromDirectory(javaRoot.concat(FilePath("lib")), {".jar"}))
{
paths.push_back(jarPath);
}
if (!paths.empty())
{
break;
}
}
return paths;
}
@@ -0,0 +1,22 @@
#ifndef JRE_SYSTEM_LIBRARY_PATH_DETECTOR_H
#define JRE_SYSTEM_LIBRARY_PATH_DETECTOR_H
#include <memory>
#include "utility/path_detector/PathDetector.h"
class JavaPathDetector;
class JreSystemLibraryPathDetector: public PathDetector
{
public:
JreSystemLibraryPathDetector(std::shared_ptr<JavaPathDetector> javaPathDetector);
virtual ~JreSystemLibraryPathDetector();
virtual std::vector<FilePath> getPaths() const;
private:
std::shared_ptr<JavaPathDetector> m_javaPathDetector;
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_H
@@ -0,0 +1,12 @@
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorLinux.h"
JreSystemLibraryPathDetectorLinux::JreSystemLibraryPathDetectorLinux(const std::string javaVersion)
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorLinux>(javaVersion))
{
}
JreSystemLibraryPathDetectorLinux::~JreSystemLibraryPathDetectorLinux()
{
}
@@ -0,0 +1,13 @@
#ifndef JRE_SYSTEM_LIBRARY_PATH_DETECTOR_LINUX_H
#define JRE_SYSTEM_LIBRARY_PATH_DETECTOR_LINUX_H
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h"
class JreSystemLibraryPathDetectorLinux: public JreSystemLibraryPathDetector
{
public:
JreSystemLibraryPathDetectorLinux(const std::string javaVersion);
virtual ~JreSystemLibraryPathDetectorLinux();
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_LINUX_H
@@ -0,0 +1,12 @@
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
JreSystemLibraryPathDetectorMac::JreSystemLibraryPathDetectorMac(const std::string javaVersion)
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorMac>(javaVersion))
{
}
JreSystemLibraryPathDetectorMac::~JreSystemLibraryPathDetectorMac()
{
}
@@ -0,0 +1,13 @@
#ifndef JRE_SYSTEM_LIBRARY_PATH_DETECTOR_MAC_H
#define JRE_SYSTEM_LIBRARY_PATH_DETECTOR_MAC_H
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h"
class JreSystemLibraryPathDetectorMac: public JreSystemLibraryPathDetector
{
public:
JreSystemLibraryPathDetectorMac(const std::string javaVersion);
virtual ~JreSystemLibraryPathDetectorMac();
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_MAC_H
@@ -0,0 +1,12 @@
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
JreSystemLibraryPathDetectorWindows::JreSystemLibraryPathDetectorWindows(const std::string javaVersion)
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorWindows>(javaVersion))
{
}
JreSystemLibraryPathDetectorWindows::~JreSystemLibraryPathDetectorWindows()
{
}
@@ -0,0 +1,13 @@
#ifndef JRE_SYSTEM_LIBRARY_PATH_DETECTOR_WINDOWS_H
#define JRE_SYSTEM_LIBRARY_PATH_DETECTOR_WINDOWS_H
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h"
class JreSystemLibraryPathDetectorWindows: public JreSystemLibraryPathDetector
{
public:
JreSystemLibraryPathDetectorWindows(const std::string javaVersion);
virtual ~JreSystemLibraryPathDetectorWindows();
};
#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_WINDOWS_H
@@ -6,6 +6,10 @@
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.h"
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.h"
#include "utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.h"
#include "utility/path_detector/maven_executable/MavenPathDetectorUnix.h"
#include "utility/path_detector/maven_executable/MavenPathDetectorWindows.h"
@@ -32,6 +36,25 @@ std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getJreSystemLibraryPathsDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
combinedDetector->addDetector(std::make_shared<JreSystemLibraryPathDetectorWindows>("1.8"));
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
combinedDetector->addDetector(std::make_shared<JreSystemLibraryPathDetectorMac>("1.8"));
}
else
{
combinedDetector->addDetector(std::make_shared<JreSystemLibraryPathDetectorLinux>("1.8"));
}
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getMavenExecutablePathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
@@ -6,6 +6,7 @@
namespace utility
{
std::shared_ptr<CombinedPathDetector> getJavaRuntimePathDetector();
std::shared_ptr<CombinedPathDetector> getJreSystemLibraryPathsDetector();
std::shared_ptr<CombinedPathDetector> getMavenExecutablePathDetector();
std::shared_ptr<CombinedPathDetector> getCxxVsHeaderPathDetector();