build: make Windows CI build and test Java language support (#1156)
This commit is contained in:
@@ -7,8 +7,11 @@
|
||||
#include "utilityApp.h"
|
||||
#include "utilityString.h"
|
||||
|
||||
JavaPathDetectorWindows::JavaPathDetectorWindows(const std::string javaVersion)
|
||||
: JavaPathDetector("Java " + javaVersion + " for Windows", javaVersion)
|
||||
JavaPathDetectorWindows::JavaPathDetectorWindows(const std::string javaVersion, bool isJre)
|
||||
: JavaPathDetector(
|
||||
"Java " + std::string(isJre ? "JRE" : "JDK") + " " + javaVersion + " for Windows",
|
||||
javaVersion)
|
||||
, m_isJre(isJre)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,25 +26,50 @@ std::vector<FilePath> JavaPathDetectorWindows::doGetPaths() const
|
||||
|
||||
key += "JavaSoft\\";
|
||||
|
||||
if (utility::isPrefix(std::string("1."), m_javaVersion))
|
||||
if (m_isJre)
|
||||
{
|
||||
key += ("Java Runtime Environment\\" + m_javaVersion).c_str();
|
||||
if (utility::isPrefix(std::string("1."), m_javaVersion))
|
||||
{
|
||||
key += ("Java Runtime Environment\\" + m_javaVersion).c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
key += ("JRE\\" + m_javaVersion).c_str();
|
||||
}
|
||||
|
||||
// NativeFormat means from Registry on Windows.
|
||||
QSettings settings(key, QSettings::NativeFormat);
|
||||
const QString value = settings.value("RuntimeLib").toString();
|
||||
|
||||
const FilePath path(value.toStdWString());
|
||||
if (path.exists())
|
||||
{
|
||||
return {path};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key += ("JRE\\" + m_javaVersion).c_str();
|
||||
key += "JDK";
|
||||
{
|
||||
const QSettings settings(key, QSettings::NativeFormat);
|
||||
for (const QString& child: settings.childGroups())
|
||||
{
|
||||
if (child.startsWith(QString::fromStdString(m_javaVersion)))
|
||||
{
|
||||
key += "\\" + child;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
const QSettings settings(key, QSettings::NativeFormat);
|
||||
const QString value = settings.value("JavaHome").toString();
|
||||
|
||||
const FilePath path = FilePath(value.toStdWString()).concatenate(L"bin/server/jvm.dll");
|
||||
if (path.exists())
|
||||
{
|
||||
return {path};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSettings expressKey(
|
||||
key, QSettings::NativeFormat); // NativeFormat means from Registry on Windows.
|
||||
QString value = expressKey.value("RuntimeLib").toString();
|
||||
|
||||
FilePath path(value.toStdWString());
|
||||
|
||||
std::vector<FilePath> paths;
|
||||
if (path.exists())
|
||||
{
|
||||
paths.push_back(path);
|
||||
}
|
||||
return paths;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
class JavaPathDetectorWindows: public JavaPathDetector
|
||||
{
|
||||
public:
|
||||
JavaPathDetectorWindows(const std::string javaVersion);
|
||||
JavaPathDetectorWindows(const std::string javaVersion, bool isJre);
|
||||
|
||||
private:
|
||||
virtual std::vector<FilePath> doGetPaths() const override;
|
||||
bool m_isJre;
|
||||
};
|
||||
|
||||
#endif // JAVA_PATH_DETECTOR_WINDOWS_H
|
||||
|
||||
+1
-1
@@ -3,6 +3,6 @@
|
||||
#include "JavaPathDetectorWindows.h"
|
||||
|
||||
JreSystemLibraryPathDetectorWindows::JreSystemLibraryPathDetectorWindows(const std::string javaVersion)
|
||||
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorWindows>(javaVersion))
|
||||
: JreSystemLibraryPathDetector(std::make_shared<JavaPathDetectorWindows>(javaVersion, true))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
|
||||
switch (utility::getOsType())
|
||||
{
|
||||
case OS_WINDOWS:
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("1.8"));
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("9"));
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("1.8", true));
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorWindows>("9", true));
|
||||
break;
|
||||
case OS_MAC:
|
||||
combinedDetector->addDetector(std::make_shared<JavaPathDetectorMac>("1.8"));
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#if BUILD_JAVA_LANGUAGE_PACKAGE
|
||||
|
||||
# include <fstream>
|
||||
# include <iostream>
|
||||
|
||||
# include "ApplicationSettings.h"
|
||||
# include "FileRegister.h"
|
||||
@@ -107,7 +106,7 @@ void processSourceFile(
|
||||
expectedOutputFilePath);
|
||||
REQUIRE_MESSAGE(
|
||||
("Output does not match the expected line count for file " + sourceFilePath.str() +
|
||||
" in project " + projectName)
|
||||
" in project " + projectName + ". Output was: " + output->getText())
|
||||
.c_str(),
|
||||
expectedOutput->getLineCount() == output->getLineCount());
|
||||
if (expectedOutput->getLineCount() == output->getLineCount())
|
||||
|
||||
@@ -241,7 +241,7 @@ void generateAndCompareExpectedOutput(
|
||||
expectedOutputFilePath);
|
||||
REQUIRE_MESSAGE(
|
||||
("Output does not match the expected line count for project \"" +
|
||||
utility::encodeToUtf8(projectName) + "\".")
|
||||
utility::encodeToUtf8(projectName) + "\". Output was: " + output->getText())
|
||||
.c_str(),
|
||||
expectedOutput->getLineCount() == output->getLineCount());
|
||||
if (expectedOutput->getLineCount() == output->getLineCount())
|
||||
|
||||
Reference in New Issue
Block a user