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:
@@ -25,6 +25,7 @@
|
||||
<source_path>./src/main/java</source_path>
|
||||
<source_path>./target/generated-sources/javacc</source_path>
|
||||
</source_paths>
|
||||
<use_jre_system_library>1</use_jre_system_library>
|
||||
<standard>8</standard>
|
||||
</source_group_7a9e75fc-2cad-42d5-8c5b-c86d02f7b4e4>
|
||||
</source_groups>
|
||||
|
||||
@@ -265,7 +265,7 @@ Id SqliteIndexStorage::addError(const std::string& message, const FilePath& file
|
||||
m_insertErrorStmt.bind(3, indexed);
|
||||
m_insertErrorStmt.bind(4, filePath.str().c_str());
|
||||
m_insertErrorStmt.bind(5, int(lineNumber));
|
||||
m_insertErrorStmt.bind(5, int(columnNumber));
|
||||
m_insertErrorStmt.bind(6, int(columnNumber));
|
||||
const bool success = executeStatement(m_insertErrorStmt);
|
||||
m_insertErrorStmt.reset();
|
||||
|
||||
|
||||
@@ -276,6 +276,21 @@ void ApplicationSettings::setJavaMaximumMemory(int size)
|
||||
setValue<int>("indexing/java/java_maximum_memory", size);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getJreSystemLibraryPaths() const
|
||||
{
|
||||
return getPathValues("indexing/java/jre_system_library_paths/jre_system_library_path");
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getJreSystemLibraryPathsExpanded() const
|
||||
{
|
||||
return expandPaths(getJreSystemLibraryPaths());
|
||||
}
|
||||
|
||||
bool ApplicationSettings::setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths)
|
||||
{
|
||||
return setPathValues("indexing/java/jre_system_library_paths/jre_system_library_path", jreSystemLibraryPaths);
|
||||
}
|
||||
|
||||
FilePath ApplicationSettings::getMavenPath() const
|
||||
{
|
||||
return FilePath(getValue<std::string>("indexing/java/maven_path", ""));
|
||||
|
||||
@@ -82,6 +82,10 @@ public:
|
||||
int getJavaMaximumMemory() const;
|
||||
void setJavaMaximumMemory(int size);
|
||||
|
||||
std::vector<FilePath> getJreSystemLibraryPaths() const;
|
||||
std::vector<FilePath> getJreSystemLibraryPathsExpanded() const;
|
||||
bool setJreSystemLibraryPaths(const std::vector<FilePath>& jreSystemLibraryPaths);
|
||||
|
||||
FilePath getMavenPath() const;
|
||||
void setMavenPath(const FilePath& path);
|
||||
|
||||
|
||||
@@ -163,7 +163,8 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::make_shared<SourceGroupSettingsJava>(id, type, this);
|
||||
javaSettings->setClasspaths(getPathValues(key + "/class_paths/class_path"));
|
||||
javaSettings->setClasspath(getPathValues(key + "/class_paths/class_path"));
|
||||
javaSettings->setUseJreSystemLibrary(getValue<bool>(key + "/use_jre_system_library", true));
|
||||
if (type == SOURCE_GROUP_JAVA_MAVEN)
|
||||
{
|
||||
javaSettings->setMavenProjectFilePath(FilePath(getValue<std::string>(key + "/maven/project_file_path", "")));
|
||||
@@ -237,7 +238,8 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector<std::shared_pt
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
if (std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(settings))
|
||||
{
|
||||
setPathValues(key + "/class_paths/class_path", javaSettings->getClasspaths());
|
||||
setPathValues(key + "/class_paths/class_path", javaSettings->getClasspath());
|
||||
setValue(key + "/use_jre_system_library", javaSettings->getUseJreSystemLibrary());
|
||||
|
||||
if (type == SOURCE_GROUP_JAVA_MAVEN)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettings(id, type, projectSettings)
|
||||
, m_classpaths(std::vector<FilePath>())
|
||||
, m_classpath(std::vector<FilePath>())
|
||||
, m_mavenProjectFilePath(FilePath())
|
||||
, m_mavenDependenciesDirectory(FilePath())
|
||||
, m_shouldIndexMavenTests(false)
|
||||
@@ -22,7 +22,8 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other)
|
||||
return (
|
||||
otherJava &&
|
||||
SourceGroupSettings::equals(other) &&
|
||||
utility::isPermutation(m_classpaths, otherJava->m_classpaths) &&
|
||||
utility::isPermutation(m_classpath, otherJava->m_classpath) &&
|
||||
m_useJreSystemLibrary == otherJava->m_useJreSystemLibrary &&
|
||||
m_mavenProjectFilePath == otherJava->m_mavenProjectFilePath &&
|
||||
m_mavenDependenciesDirectory == otherJava->m_mavenDependenciesDirectory &&
|
||||
m_shouldIndexMavenTests == otherJava->m_shouldIndexMavenTests
|
||||
@@ -34,19 +35,29 @@ std::vector<std::string> SourceGroupSettingsJava::getAvailableLanguageStandards(
|
||||
return std::vector<std::string>(1, "8");
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsJava::getClasspaths() const
|
||||
bool SourceGroupSettingsJava::getUseJreSystemLibrary() const
|
||||
{
|
||||
return m_classpaths;
|
||||
return m_useJreSystemLibrary;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsJava::getClasspathsExpandedAndAbsolute() const
|
||||
void SourceGroupSettingsJava::setUseJreSystemLibrary(bool useJreSystemLibrary)
|
||||
{
|
||||
return m_projectSettings->makePathsExpandedAndAbsolute(getClasspaths());
|
||||
m_useJreSystemLibrary = useJreSystemLibrary;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setClasspaths(const std::vector<FilePath>& classpaths)
|
||||
std::vector<FilePath> SourceGroupSettingsJava::getClasspath() const
|
||||
{
|
||||
m_classpaths = classpaths;
|
||||
return m_classpath;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettingsJava::getClasspathExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathsExpandedAndAbsolute(getClasspath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setClasspath(const std::vector<FilePath>& classpath)
|
||||
{
|
||||
m_classpath = classpath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenProjectFilePath() const
|
||||
|
||||
@@ -17,9 +17,12 @@ public:
|
||||
|
||||
virtual std::vector<std::string> getAvailableLanguageStandards() const;
|
||||
|
||||
std::vector<FilePath> getClasspaths() const;
|
||||
std::vector<FilePath> getClasspathsExpandedAndAbsolute() const;
|
||||
void setClasspaths(const std::vector<FilePath>& classpaths);
|
||||
bool getUseJreSystemLibrary() const;
|
||||
void setUseJreSystemLibrary(bool useJreSystemLibrary);
|
||||
|
||||
std::vector<FilePath> getClasspath() const;
|
||||
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
|
||||
void setClasspath(const std::vector<FilePath>& classpath);
|
||||
|
||||
FilePath getMavenProjectFilePath() const;
|
||||
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
|
||||
@@ -36,7 +39,8 @@ private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
|
||||
std::vector<FilePath> m_classpaths;
|
||||
bool m_useJreSystemLibrary;
|
||||
std::vector<FilePath> m_classpath;
|
||||
FilePath m_mavenProjectFilePath;
|
||||
FilePath m_mavenDependenciesDirectory;
|
||||
bool m_shouldIndexMavenTests;
|
||||
|
||||
@@ -239,6 +239,15 @@ add_files(
|
||||
utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp
|
||||
utility/path_detector/java_runtime/JavaPathDetectorWindows.h
|
||||
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.cpp
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.cpp
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.h
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.cpp
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.h
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.cpp
|
||||
utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.h
|
||||
|
||||
utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp
|
||||
utility/path_detector/maven_executable/MavenPathDetectorUnix.h
|
||||
utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "qt/element/QtDirectoryListBox.h"
|
||||
#include "qt/window/QtSelectPathsDialog.h"
|
||||
@@ -221,7 +222,7 @@ QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader(
|
||||
);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsCDBHeader::populate( QGridLayout* layout, int& row)
|
||||
void QtProjectWizzardContentPathsCDBHeader::populate(QGridLayout* layout, int& row)
|
||||
{
|
||||
QtProjectWizzardContentPaths::populate(layout, row);
|
||||
|
||||
@@ -479,12 +480,26 @@ QtProjectWizzardContentPathsClassJava::QtProjectWizzardContentPathsClassJava(
|
||||
);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsClassJava::populate(QGridLayout* layout, int& row)
|
||||
{
|
||||
QtProjectWizzardContentPaths::populate(layout, row);
|
||||
|
||||
QLabel* label = createFormLabel("JRE System Library");
|
||||
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
|
||||
|
||||
m_useJreSystemLibraryCheckBox = new QCheckBox("Use JRE System Library", this);
|
||||
|
||||
layout->addWidget(m_useJreSystemLibraryCheckBox, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathsClassJava::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
if (javaSettings)
|
||||
{
|
||||
m_list->setList(javaSettings->getClasspaths());
|
||||
m_list->setList(javaSettings->getClasspath());
|
||||
m_useJreSystemLibraryCheckBox->setChecked(javaSettings->getUseJreSystemLibrary());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,6 +508,7 @@ void QtProjectWizzardContentPathsClassJava::save()
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
if (javaSettings)
|
||||
{
|
||||
javaSettings->setClasspaths(m_list->getList());
|
||||
javaSettings->setClasspath(m_list->getList());
|
||||
javaSettings->setUseJreSystemLibrary(m_useJreSystemLibraryCheckBox->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
||||
#include "utility/path_detector/CombinedPathDetector.h"
|
||||
|
||||
class QtDirectoryListBox;
|
||||
class QPushButton;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
class QtDirectoryListBox;
|
||||
class SourceGroupSettings;
|
||||
|
||||
class QtProjectWizzardContentPaths
|
||||
@@ -153,8 +154,12 @@ public:
|
||||
QtProjectWizzardContentPathsClassJava(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row);
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
|
||||
private:
|
||||
QCheckBox* m_useJreSystemLibraryCheckBox;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_PATHS_H
|
||||
|
||||
@@ -155,90 +155,112 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
|
||||
// Java
|
||||
addTitle("JAVA", layout, row);
|
||||
|
||||
// jvm library path
|
||||
m_javaPath = new QtLocationPicker(this);
|
||||
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_javaPath->setFileFilter("JVM Library (jvm.dll)");
|
||||
m_javaPath->setPlaceholderText("<jre_path>/bin/client/jvm.dll");
|
||||
// jvm library path
|
||||
m_javaPath = new QtLocationPicker(this);
|
||||
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_javaPath->setFileFilter("JVM Library (jvm.dll)");
|
||||
m_javaPath->setPlaceholderText("<jre_path>/bin/client/jvm.dll");
|
||||
}
|
||||
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
m_javaPath->setFileFilter("JLI or JVM Library (libjli.dylib libjvm.dylib)");
|
||||
m_javaPath->setPlaceholderText("<jre_path>/Contents/Home/jre/lib/jli/libjli.dylib");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_javaPath->setFileFilter("JVM Library (libjvm.so)");
|
||||
m_javaPath->setPlaceholderText("<jre_path>/bin/<arch>/server/libjvm.so");
|
||||
}
|
||||
|
||||
addLabelAndWidget("Java Path", m_javaPath, layout, row);
|
||||
|
||||
std::string javaVersionString = "";
|
||||
switch (utility::getApplicationArchitectureType())
|
||||
{
|
||||
case APPLICATION_ARCHITECTURE_X86_32:
|
||||
javaVersionString = "32 Bit ";
|
||||
break;
|
||||
case APPLICATION_ARCHITECTURE_X86_64:
|
||||
javaVersionString = "64 Bit ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
javaVersionString += "Java 8";
|
||||
|
||||
addHelpButton((
|
||||
"<p>Only required for indexing Java projects.</p>"
|
||||
"<p>Provide the location of the jvm library inside the installation of your " + javaVersionString +
|
||||
" runtime environment (for information on how to set this take a look at "
|
||||
"<a href=\"https://sourcetrail.com/documentation/#FindingJavaRuntimeLibraryLocation\">"
|
||||
"Finding Java Runtime Library Location</a> or use the auto detection below)</p>").c_str(),
|
||||
layout, row
|
||||
);
|
||||
row++;
|
||||
|
||||
m_javaPathDetector = utility::getJavaRuntimePathDetector();
|
||||
addJavaPathDetection(layout, row);
|
||||
}
|
||||
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
|
||||
{
|
||||
m_javaPath->setFileFilter("JLI or JVM Library (libjli.dylib libjvm.dylib)");
|
||||
m_javaPath->setPlaceholderText("<jre_path>/Contents/Home/jre/lib/jli/libjli.dylib");
|
||||
// jvm max memory
|
||||
m_jvmMaximumMemory = addLineEdit(
|
||||
"JVM Maximum Memory",
|
||||
"<p>Specify the maximum amount of memory that will be allocated by the indexer's JVM (values are in MB). Set "
|
||||
"this value to -1 to use the JVM's default setting.</p>"
|
||||
"<p><b>Warning</b>: You may experience a sudden slowdown during the course of indexing when setting this value "
|
||||
"too low. This may also happen when using the JVM's default setting.</p>",
|
||||
layout, row
|
||||
);
|
||||
layout->setRowMinimumHeight(row - 1, 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_javaPath->setFileFilter("JVM Library (libjvm.so)");
|
||||
m_javaPath->setPlaceholderText("<jre_path>/bin/<arch>/server/libjvm.so");
|
||||
// JRE System Library
|
||||
const QString title = "JRE System Library";
|
||||
QLabel* label = createFormLabel(title);
|
||||
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
|
||||
|
||||
addHelpButton(
|
||||
"<p>Only required for indexing Java projects.</p>"
|
||||
"<p>Add the jar files of your JRE System Library. These jars can be found inside your JRE install directory.</p>", layout, row);
|
||||
|
||||
m_jreSystemLibraryPaths = new QtDirectoryListBox(this, title);
|
||||
|
||||
layout->addWidget(m_jreSystemLibraryPaths, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
m_jreSystemLibraryPathsDetector = utility::getJreSystemLibraryPathsDetector();
|
||||
addJreSystemLibraryPathsDetection(layout, row);
|
||||
}
|
||||
|
||||
addLabelAndWidget("Java Path", m_javaPath, layout, row);
|
||||
|
||||
std::string javaVersionString = "";
|
||||
switch (utility::getApplicationArchitectureType())
|
||||
{
|
||||
case APPLICATION_ARCHITECTURE_X86_32:
|
||||
javaVersionString = "32 Bit ";
|
||||
break;
|
||||
case APPLICATION_ARCHITECTURE_X86_64:
|
||||
javaVersionString = "64 Bit ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// maven path
|
||||
m_mavenPath = new QtLocationPicker(this);
|
||||
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_mavenPath->setFileFilter("Maven command (mvn.cmd)");
|
||||
m_mavenPath->setPlaceholderText("<maven_path>/bin/mvn.cmd");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mavenPath->setFileFilter("Maven command (mvn)");
|
||||
m_mavenPath->setPlaceholderText("<binarypath>/mvn");
|
||||
}
|
||||
|
||||
addLabelAndWidget("Maven Path", m_mavenPath, layout, row);
|
||||
|
||||
addHelpButton(
|
||||
"<p>Only required for indexing projects using Maven.</p>"
|
||||
"<p>Provide the location of your installed Maven executable. You can also use the auto detection below.</p>"
|
||||
, layout, row
|
||||
);
|
||||
row++;
|
||||
|
||||
m_mavenPathDetector = utility::getMavenExecutablePathDetector();
|
||||
addMavenPathDetection(layout, row);
|
||||
}
|
||||
javaVersionString += "Java 8";
|
||||
|
||||
addHelpButton((
|
||||
"<p>Only required for indexing Java projects.</p>"
|
||||
"<p>Provide the location of the jvm library inside the installation of your " + javaVersionString +
|
||||
" runtime environment (for information on how to set this take a look at "
|
||||
"<a href=\"https://sourcetrail.com/documentation/#FindingJavaRuntimeLibraryLocation\">"
|
||||
"Finding Java Runtime Library Location</a> or use the auto detection below)</p>").c_str(),
|
||||
layout, row
|
||||
);
|
||||
row++;
|
||||
|
||||
m_javaPathDetector = utility::getJavaRuntimePathDetector();
|
||||
addJavaPathDetection(layout, row);
|
||||
|
||||
// jvm max memory
|
||||
m_jvmMaximumMemory = addLineEdit(
|
||||
"JVM Maximum Memory",
|
||||
"<p>Specify the maximum amount of memory that will be allocated by the indexer's JVM (values are in MB). Set "
|
||||
"this value to -1 to use the JVM's default setting.</p>"
|
||||
"<p><b>Warning</b>: You may experience a sudden slowdown during the course of indexing when setting this value "
|
||||
"too low. This may also happen when using the JVM's default setting.</p>",
|
||||
layout, row
|
||||
);
|
||||
layout->setRowMinimumHeight(row - 1, 30);
|
||||
|
||||
// maven path
|
||||
m_mavenPath = new QtLocationPicker(this);
|
||||
|
||||
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
|
||||
{
|
||||
m_mavenPath->setFileFilter("Maven command (mvn.cmd)");
|
||||
m_mavenPath->setPlaceholderText("<maven_path>/bin/mvn.cmd");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mavenPath->setFileFilter("Maven command (mvn)");
|
||||
m_mavenPath->setPlaceholderText("<binarypath>/mvn");
|
||||
}
|
||||
|
||||
addLabelAndWidget("Maven Path", m_mavenPath, layout, row);
|
||||
|
||||
addHelpButton(
|
||||
"<p>Only required for indexing projects using Maven.</p>"
|
||||
"<p>Provide the location of your installed Maven executable. You can also use the auto detection below.</p>"
|
||||
, layout, row
|
||||
);
|
||||
row++;
|
||||
|
||||
m_mavenPathDetector = utility::getMavenExecutablePathDetector();
|
||||
addMavenPathDetection(layout, row);
|
||||
|
||||
addGap(layout, row);
|
||||
|
||||
@@ -290,6 +312,8 @@ void QtProjectWizzardContentPreferences::load()
|
||||
|
||||
m_jvmMaximumMemory->setText(QString::number(appSettings->getJavaMaximumMemory()));
|
||||
|
||||
m_jreSystemLibraryPaths->setList(appSettings->getJreSystemLibraryPaths());
|
||||
|
||||
if (m_mavenPath)
|
||||
{
|
||||
m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath().str()));
|
||||
@@ -332,6 +356,8 @@ void QtProjectWizzardContentPreferences::save()
|
||||
appSettings->setJavaPath(m_javaPath->getText().toStdString());
|
||||
}
|
||||
|
||||
appSettings->setJreSystemLibraryPaths(m_jreSystemLibraryPaths->getList());
|
||||
|
||||
int jvmMaximumMemory = m_jvmMaximumMemory->text().toInt();
|
||||
if (jvmMaximumMemory) appSettings->setJavaMaximumMemory(jvmMaximumMemory);
|
||||
|
||||
@@ -363,6 +389,13 @@ void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPreferences::jreSystemLibraryPathsDetectionClicked()
|
||||
{
|
||||
std::vector<FilePath> paths = m_jreSystemLibraryPathsDetector->getPaths(m_jreSystemLibraryPathsDetectorBox->currentText().toStdString());
|
||||
std::vector<FilePath> oldPaths = m_jreSystemLibraryPaths->getList();
|
||||
m_jreSystemLibraryPaths->setList(utility::unique(utility::concat(oldPaths, paths)));
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPreferences::mavenPathDetectionClicked()
|
||||
{
|
||||
std::vector<FilePath> paths = m_mavenPathDetector->getPaths(m_mavenPathDetectorBox->currentText().toStdString());
|
||||
@@ -424,6 +457,40 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPreferences::addJreSystemLibraryPathsDetection(QGridLayout* layout, int& row)
|
||||
{
|
||||
const std::vector<std::string> detectorNames = m_jreSystemLibraryPathsDetector->getWorkingDetectorNames();
|
||||
if (detectorNames.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QLabel* label = new QLabel("Auto detection from:");
|
||||
|
||||
m_jreSystemLibraryPathsDetectorBox = new QComboBox();
|
||||
|
||||
for (const std::string& detectorName: detectorNames)
|
||||
{
|
||||
m_jreSystemLibraryPathsDetectorBox->addItem(detectorName.c_str());
|
||||
}
|
||||
|
||||
QPushButton* button = new QPushButton("detect");
|
||||
button->setObjectName("windowButton");
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(jreSystemLibraryPathsDetectionClicked()));
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout();
|
||||
hlayout->setContentsMargins(0, 0, 0, 0);
|
||||
hlayout->addWidget(label);
|
||||
hlayout->addWidget(m_jreSystemLibraryPathsDetectorBox);
|
||||
hlayout->addWidget(button);
|
||||
|
||||
QWidget* detectionWidget = new QWidget();
|
||||
detectionWidget->setLayout(hlayout);
|
||||
|
||||
layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPreferences::addMavenPathDetection(QGridLayout* layout, int& row)
|
||||
{
|
||||
std::vector<std::string> detectorNames = m_mavenPathDetector->getWorkingDetectorNames();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "qt/element/QtFontPicker.h"
|
||||
#include "qt/element/QtLocationPicker.h"
|
||||
#include "qt/element/QtDirectoryListBox.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
||||
#include "utility/path_detector/CombinedPathDetector.h"
|
||||
|
||||
@@ -30,12 +31,14 @@ public:
|
||||
private slots:
|
||||
void colorSchemeChanged(int index);
|
||||
void javaPathDetectionClicked();
|
||||
void jreSystemLibraryPathsDetectionClicked();
|
||||
void mavenPathDetectionClicked();
|
||||
void loggingEnabledChanged();
|
||||
void indexerThreadsChanges(int index);
|
||||
|
||||
private:
|
||||
void addJavaPathDetection(QGridLayout* layout, int& row);
|
||||
void addJreSystemLibraryPathsDetection(QGridLayout* layout, int& row);
|
||||
void addMavenPathDetection(QGridLayout* layout, int& row);
|
||||
|
||||
void addTitle(QString title, QGridLayout* layout, int& row);
|
||||
@@ -72,13 +75,16 @@ private:
|
||||
QCheckBox* m_multiProcessIndexing;
|
||||
|
||||
std::shared_ptr<CombinedPathDetector> m_javaPathDetector;
|
||||
std::shared_ptr<CombinedPathDetector> m_jreSystemLibraryPathsDetector;
|
||||
std::shared_ptr<CombinedPathDetector> m_mavenPathDetector;
|
||||
|
||||
QComboBox* m_javaPathDetectorBox;
|
||||
QComboBox* m_jreSystemLibraryPathsDetectorBox;
|
||||
QComboBox* m_mavenPathDetectorBox;
|
||||
QtLocationPicker* m_javaPath;
|
||||
QtLocationPicker* m_mavenPath;
|
||||
QtDirectoryListBox* m_jreSystemLibraryPaths;
|
||||
QLineEdit* m_jvmMaximumMemory;
|
||||
QtLocationPicker* m_mavenPath;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_PREFERENCES_H
|
||||
|
||||
@@ -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
|
||||
+12
@@ -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()
|
||||
{
|
||||
}
|
||||
+13
@@ -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
|
||||
+12
@@ -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()
|
||||
{
|
||||
}
|
||||
+13
@@ -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
|
||||
+12
@@ -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()
|
||||
{
|
||||
}
|
||||
+13
@@ -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();
|
||||
|
||||
@@ -184,7 +184,7 @@ std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
|
||||
std::vector<FilePath> classPath;
|
||||
|
||||
for (const FilePath& classpath: m_settings->getClasspathsExpandedAndAbsolute())
|
||||
for (const FilePath& classpath: m_settings->getClasspathExpandedAndAbsolute())
|
||||
{
|
||||
if (classpath.exists())
|
||||
{
|
||||
@@ -193,6 +193,15 @@ std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_settings->getUseJreSystemLibrary())
|
||||
{
|
||||
for (const FilePath& systemLibraryPath: ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded())
|
||||
{
|
||||
LOG_INFO("Adding JRE system library path to classpath: " + systemLibraryPath.str());
|
||||
classPath.push_back(systemLibraryPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::vector<FilePath> mavenJarPaths = FileSystem::getFilePathsFromDirectory(
|
||||
|
||||
Reference in New Issue
Block a user