diff --git a/bin/app/user/projects/javaparser/javaparser.srctrlprj b/bin/app/user/projects/javaparser/javaparser.srctrlprj index 150b8f43..5c8e11d3 100644 --- a/bin/app/user/projects/javaparser/javaparser.srctrlprj +++ b/bin/app/user/projects/javaparser/javaparser.srctrlprj @@ -25,6 +25,7 @@ ./src/main/java ./target/generated-sources/javacc + 1 8 diff --git a/src/lib/data/SqliteIndexStorage.cpp b/src/lib/data/SqliteIndexStorage.cpp index de9e185b..ebd472a3 100644 --- a/src/lib/data/SqliteIndexStorage.cpp +++ b/src/lib/data/SqliteIndexStorage.cpp @@ -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(); diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp index a52bea7f..aeae3f00 100644 --- a/src/lib/settings/ApplicationSettings.cpp +++ b/src/lib/settings/ApplicationSettings.cpp @@ -276,6 +276,21 @@ void ApplicationSettings::setJavaMaximumMemory(int size) setValue("indexing/java/java_maximum_memory", size); } +std::vector ApplicationSettings::getJreSystemLibraryPaths() const +{ + return getPathValues("indexing/java/jre_system_library_paths/jre_system_library_path"); +} + +std::vector ApplicationSettings::getJreSystemLibraryPathsExpanded() const +{ + return expandPaths(getJreSystemLibraryPaths()); +} + +bool ApplicationSettings::setJreSystemLibraryPaths(const std::vector& jreSystemLibraryPaths) +{ + return setPathValues("indexing/java/jre_system_library_paths/jre_system_library_path", jreSystemLibraryPaths); +} + FilePath ApplicationSettings::getMavenPath() const { return FilePath(getValue("indexing/java/maven_path", "")); diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h index 9b5ef7f3..23852e0d 100644 --- a/src/lib/settings/ApplicationSettings.h +++ b/src/lib/settings/ApplicationSettings.h @@ -82,6 +82,10 @@ public: int getJavaMaximumMemory() const; void setJavaMaximumMemory(int size); + std::vector getJreSystemLibraryPaths() const; + std::vector getJreSystemLibraryPathsExpanded() const; + bool setJreSystemLibraryPaths(const std::vector& jreSystemLibraryPaths); + FilePath getMavenPath() const; void setMavenPath(const FilePath& path); diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index c2a3bc10..b043d772 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -163,7 +163,8 @@ std::vector> ProjectSettings::getAllSourceG case SOURCE_GROUP_JAVA_MAVEN: { std::shared_ptr javaSettings = std::make_shared(id, type, this); - javaSettings->setClasspaths(getPathValues(key + "/class_paths/class_path")); + javaSettings->setClasspath(getPathValues(key + "/class_paths/class_path")); + javaSettings->setUseJreSystemLibrary(getValue(key + "/use_jre_system_library", true)); if (type == SOURCE_GROUP_JAVA_MAVEN) { javaSettings->setMavenProjectFilePath(FilePath(getValue(key + "/maven/project_file_path", ""))); @@ -237,7 +238,8 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector javaSettings = std::dynamic_pointer_cast(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) { diff --git a/src/lib/settings/SourceGroupSettingsJava.cpp b/src/lib/settings/SourceGroupSettingsJava.cpp index 25f03426..2bcef532 100644 --- a/src/lib/settings/SourceGroupSettingsJava.cpp +++ b/src/lib/settings/SourceGroupSettingsJava.cpp @@ -4,7 +4,7 @@ SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings) : SourceGroupSettings(id, type, projectSettings) - , m_classpaths(std::vector()) + , m_classpath(std::vector()) , m_mavenProjectFilePath(FilePath()) , m_mavenDependenciesDirectory(FilePath()) , m_shouldIndexMavenTests(false) @@ -22,7 +22,8 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr 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 SourceGroupSettingsJava::getAvailableLanguageStandards( return std::vector(1, "8"); } -std::vector SourceGroupSettingsJava::getClasspaths() const +bool SourceGroupSettingsJava::getUseJreSystemLibrary() const { - return m_classpaths; + return m_useJreSystemLibrary; } -std::vector SourceGroupSettingsJava::getClasspathsExpandedAndAbsolute() const +void SourceGroupSettingsJava::setUseJreSystemLibrary(bool useJreSystemLibrary) { - return m_projectSettings->makePathsExpandedAndAbsolute(getClasspaths()); + m_useJreSystemLibrary = useJreSystemLibrary; } -void SourceGroupSettingsJava::setClasspaths(const std::vector& classpaths) +std::vector SourceGroupSettingsJava::getClasspath() const { - m_classpaths = classpaths; + return m_classpath; +} + +std::vector SourceGroupSettingsJava::getClasspathExpandedAndAbsolute() const +{ + return m_projectSettings->makePathsExpandedAndAbsolute(getClasspath()); +} + +void SourceGroupSettingsJava::setClasspath(const std::vector& classpath) +{ + m_classpath = classpath; } FilePath SourceGroupSettingsJava::getMavenProjectFilePath() const diff --git a/src/lib/settings/SourceGroupSettingsJava.h b/src/lib/settings/SourceGroupSettingsJava.h index c7956355..996b7401 100644 --- a/src/lib/settings/SourceGroupSettingsJava.h +++ b/src/lib/settings/SourceGroupSettingsJava.h @@ -17,9 +17,12 @@ public: virtual std::vector getAvailableLanguageStandards() const; - std::vector getClasspaths() const; - std::vector getClasspathsExpandedAndAbsolute() const; - void setClasspaths(const std::vector& classpaths); + bool getUseJreSystemLibrary() const; + void setUseJreSystemLibrary(bool useJreSystemLibrary); + + std::vector getClasspath() const; + std::vector getClasspathExpandedAndAbsolute() const; + void setClasspath(const std::vector& classpath); FilePath getMavenProjectFilePath() const; FilePath getMavenProjectFilePathExpandedAndAbsolute() const; @@ -36,7 +39,8 @@ private: virtual std::vector getDefaultSourceExtensions() const; virtual std::string getDefaultStandard() const; - std::vector m_classpaths; + bool m_useJreSystemLibrary; + std::vector m_classpath; FilePath m_mavenProjectFilePath; FilePath m_mavenDependenciesDirectory; bool m_shouldIndexMavenTests; diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index 72a2c89f..9f829755 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -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 diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 8dbb774d..18999f7d 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -1,9 +1,10 @@ #include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h" +#include +#include #include #include #include -#include #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 javaSettings = std::dynamic_pointer_cast(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 javaSettings = std::dynamic_pointer_cast(m_settings); if (javaSettings) { - javaSettings->setClasspaths(m_list->getList()); + javaSettings->setClasspath(m_list->getList()); + javaSettings->setUseJreSystemLibrary(m_useJreSystemLibraryCheckBox->isChecked()); } } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index 1106ffc9..466b2cfb 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -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 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 diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index f1d50aa9..c8a90cd1 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -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("/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("/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("/Contents/Home/jre/lib/jli/libjli.dylib"); + } + else + { + m_javaPath->setFileFilter("JVM Library (libjvm.so)"); + m_javaPath->setPlaceholderText("/bin//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(( + "

Only required for indexing Java projects.

" + "

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 " + "" + "Finding Java Runtime Library Location or use the auto detection below)

").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("/Contents/Home/jre/lib/jli/libjli.dylib"); + // jvm max memory + m_jvmMaximumMemory = addLineEdit( + "JVM Maximum Memory", + "

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.

" + "

Warning: 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.

", + layout, row + ); + layout->setRowMinimumHeight(row - 1, 30); } - else { - m_javaPath->setFileFilter("JVM Library (libjvm.so)"); - m_javaPath->setPlaceholderText("/bin//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( + "

Only required for indexing Java projects.

" + "

Add the jar files of your JRE System Library. These jars can be found inside your JRE install directory.

", 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("/bin/mvn.cmd"); + } + else + { + m_mavenPath->setFileFilter("Maven command (mvn)"); + m_mavenPath->setPlaceholderText("/mvn"); + } + + addLabelAndWidget("Maven Path", m_mavenPath, layout, row); + + addHelpButton( + "

Only required for indexing projects using Maven.

" + "

Provide the location of your installed Maven executable. You can also use the auto detection below.

" + , layout, row + ); + row++; + + m_mavenPathDetector = utility::getMavenExecutablePathDetector(); + addMavenPathDetection(layout, row); } - javaVersionString += "Java 8"; - - addHelpButton(( - "

Only required for indexing Java projects.

" - "

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 " - "" - "Finding Java Runtime Library Location or use the auto detection below)

").c_str(), - layout, row - ); - row++; - - m_javaPathDetector = utility::getJavaRuntimePathDetector(); - addJavaPathDetection(layout, row); - - // jvm max memory - m_jvmMaximumMemory = addLineEdit( - "JVM Maximum Memory", - "

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.

" - "

Warning: 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.

", - 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("/bin/mvn.cmd"); - } - else - { - m_mavenPath->setFileFilter("Maven command (mvn)"); - m_mavenPath->setPlaceholderText("/mvn"); - } - - addLabelAndWidget("Maven Path", m_mavenPath, layout, row); - - addHelpButton( - "

Only required for indexing projects using Maven.

" - "

Provide the location of your installed Maven executable. You can also use the auto detection below.

" - , 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 paths = m_jreSystemLibraryPathsDetector->getPaths(m_jreSystemLibraryPathsDetectorBox->currentText().toStdString()); + std::vector oldPaths = m_jreSystemLibraryPaths->getList(); + m_jreSystemLibraryPaths->setList(utility::unique(utility::concat(oldPaths, paths))); +} + void QtProjectWizzardContentPreferences::mavenPathDetectionClicked() { std::vector 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 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 detectorNames = m_mavenPathDetector->getWorkingDetectorNames(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h index b45bbc0b..cfb399cc 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h @@ -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 m_javaPathDetector; + std::shared_ptr m_jreSystemLibraryPathsDetector; std::shared_ptr 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 diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.cpp b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.cpp new file mode 100644 index 00000000..9939a501 --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.cpp @@ -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) + : PathDetector("JRE System Library") + , m_javaPathDetector(javaPathDetector) +{ +} + +JreSystemLibraryPathDetector::~JreSystemLibraryPathDetector() +{ +} + +std::vector JreSystemLibraryPathDetector::getPaths() const +{ + std::vector 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; +} diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h new file mode 100644 index 00000000..9c9196bc --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetector.h @@ -0,0 +1,22 @@ +#ifndef JRE_SYSTEM_LIBRARY_PATH_DETECTOR_H +#define JRE_SYSTEM_LIBRARY_PATH_DETECTOR_H + +#include + +#include "utility/path_detector/PathDetector.h" + +class JavaPathDetector; + +class JreSystemLibraryPathDetector: public PathDetector +{ +public: + JreSystemLibraryPathDetector(std::shared_ptr javaPathDetector); + virtual ~JreSystemLibraryPathDetector(); + + virtual std::vector getPaths() const; + +private: + std::shared_ptr m_javaPathDetector; +}; + +#endif // JRE_SYSTEM_LIBRARY_PATH_DETECTOR_H diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.cpp b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.cpp new file mode 100644 index 00000000..793cefba --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.cpp @@ -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(javaVersion)) +{ +} + +JreSystemLibraryPathDetectorLinux::~JreSystemLibraryPathDetectorLinux() +{ +} diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.h b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.h new file mode 100644 index 00000000..4a5226ed --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorLinux.h @@ -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 diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.cpp b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.cpp new file mode 100644 index 00000000..5621c66b --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.cpp @@ -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(javaVersion)) +{ +} + +JreSystemLibraryPathDetectorMac::~JreSystemLibraryPathDetectorMac() +{ +} diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.h b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.h new file mode 100644 index 00000000..c508d32d --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorMac.h @@ -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 diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.cpp b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.cpp new file mode 100644 index 00000000..9cce4a95 --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.cpp @@ -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(javaVersion)) +{ +} + +JreSystemLibraryPathDetectorWindows::~JreSystemLibraryPathDetectorWindows() +{ +} diff --git a/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.h b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.h new file mode 100644 index 00000000..68d82bf9 --- /dev/null +++ b/src/lib_gui/utility/path_detector/jre_system_library/JreSystemLibraryPathDetectorWindows.h @@ -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 diff --git a/src/lib_gui/utility/utilityPathDetection.cpp b/src/lib_gui/utility/utilityPathDetection.cpp index 8a9e78f3..a5721ea0 100644 --- a/src/lib_gui/utility/utilityPathDetection.cpp +++ b/src/lib_gui/utility/utilityPathDetection.cpp @@ -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 utility::getJavaRuntimePathDetector() return combinedDetector; } +std::shared_ptr utility::getJreSystemLibraryPathsDetector() +{ + std::shared_ptr combinedDetector = std::make_shared(); + if (QSysInfo::windowsVersion() != QSysInfo::WV_None) + { + combinedDetector->addDetector(std::make_shared("1.8")); + } + else if (QSysInfo::macVersion() != QSysInfo::MV_None) + { + combinedDetector->addDetector(std::make_shared("1.8")); + } + else + { + combinedDetector->addDetector(std::make_shared("1.8")); + } + + return combinedDetector; +} + std::shared_ptr utility::getMavenExecutablePathDetector() { std::shared_ptr combinedDetector = std::make_shared(); diff --git a/src/lib_gui/utility/utilityPathDetection.h b/src/lib_gui/utility/utilityPathDetection.h index 0030e321..893c97fd 100644 --- a/src/lib_gui/utility/utilityPathDetection.h +++ b/src/lib_gui/utility/utilityPathDetection.h @@ -6,6 +6,7 @@ namespace utility { std::shared_ptr getJavaRuntimePathDetector(); + std::shared_ptr getJreSystemLibraryPathsDetector(); std::shared_ptr getMavenExecutablePathDetector(); std::shared_ptr getCxxVsHeaderPathDetector(); diff --git a/src/lib_java/project/SourceGroupJava.cpp b/src/lib_java/project/SourceGroupJava.cpp index 722c5a29..7c5cb62b 100644 --- a/src/lib_java/project/SourceGroupJava.cpp +++ b/src/lib_java/project/SourceGroupJava.cpp @@ -184,7 +184,7 @@ std::vector SourceGroupJava::getClassPath() std::vector classPath; - for (const FilePath& classpath: m_settings->getClasspathsExpandedAndAbsolute()) + for (const FilePath& classpath: m_settings->getClasspathExpandedAndAbsolute()) { if (classpath.exists()) { @@ -193,6 +193,15 @@ std::vector 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 mavenJarPaths = FileSystem::getFilePathsFromDirectory(