logic: allow to specify custom Maven settings.xml file in project settings (issue #794) (#847)

This commit is contained in:
Malte Langkabel
2019-12-11 14:00:20 +01:00
committed by GitHub
parent d33a5357dd
commit 3932bb1fb8
10 changed files with 159 additions and 11 deletions
+2
View File
@@ -356,6 +356,8 @@ if (BUILD_JAVA_LANGUAGE_PACKAGE)
add_files(
LIB_GUI
qt/project_wizard/content/path/QtProjectWizardContentPathSettingsMaven.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathSettingsMaven.h
qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.cpp
qt/project_wizard/content/path/QtProjectWizardContentPathSourceGradle.h
qt/project_wizard/content/path/QtProjectWizardContentPathSourceMaven.cpp
@@ -60,6 +60,7 @@
#if BUILD_JAVA_LANGUAGE_PACKAGE
# include "QtProjectWizardContentJavaStandard.h"
# include "QtProjectWizardContentPathSettingsMaven.h"
# include "QtProjectWizardContentPathSourceGradle.h"
# include "QtProjectWizardContentPathSourceMaven.h"
# include "QtProjectWizardContentPathsClassJava.h"
@@ -421,6 +422,8 @@ std::vector<QtSourceGroupWizardPage<SourceGroupSettingsJavaMaven>> getSourceGrou
WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathSourceMaven>(
WIZARD_CONTENT_CONTEXT_ALL);
page.addContentCreatorWithSettings<QtProjectWizardContentPathSettingsMaven>(
WIZARD_CONTENT_CONTEXT_ALL);
pages.push_back(page);
}
{
@@ -0,0 +1,52 @@
#include "QtProjectWizardContentPathSettingsMaven.h"
#include <QCheckBox>
//#include "Application.h"
//#include "ApplicationSettings.h"
//#include "MessageStatus.h"
//#include "QtDialogView.h"
//#include "ScopedFunctor.h"
//#include "SourceGroupJavaMaven.h"
#include "SourceGroupSettingsJavaMaven.h"
//#include "logging.h"
//#include "utility.h"
//#include "utilityFile.h"
//#include "utilityMaven.h"
QtProjectWizardContentPathSettingsMaven::QtProjectWizardContentPathSettingsMaven(
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window)
: QtProjectWizardContentPath(window), m_settings(settings)
{
setTitleString("Maven Settings File (settings.xml)");
setHelpString(
"If your project uses a custom Maven settings file, specify it here. "
"If you leave this option empty, the default Maven settings will be used.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}.");
setPlaceholderString("Use Default");
setAllowEmpty(true);
setFileEndings({L".xml"});
}
void QtProjectWizardContentPathSettingsMaven::populate(QGridLayout* layout, int& row)
{
QtProjectWizardContentPath::populate(layout, row);
m_picker->setPickDirectory(false);
m_picker->setFileFilter("Settings File (*.xml)");
}
void QtProjectWizardContentPathSettingsMaven::load()
{
m_picker->setText(QString::fromStdWString(m_settings->getMavenSettingsFilePath().wstr()));
}
void QtProjectWizardContentPathSettingsMaven::save()
{
m_settings->setMavenSettingsFilePath(FilePath(m_picker->getText().toStdWString()));
}
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathSettingsMaven::getSourceGroupSettings()
{
return m_settings;
}
@@ -0,0 +1,29 @@
#ifndef QT_PROJECT_WIZARD_CONTENT_PATH_SETTINGS_MAVEN_H
#define QT_PROJECT_WIZARD_CONTENT_PATH_SETTINGS_MAVEN_H
#include "QtProjectWizardContentPath.h"
class QCheckBox;
class SourceGroupSettingsJavaMaven;
class QtProjectWizardContentPathSettingsMaven: public QtProjectWizardContentPath
{
Q_OBJECT
public:
QtProjectWizardContentPathSettingsMaven(
std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window);
// QtProjectWizardContent implementation
void populate(QGridLayout* layout, int& row) override;
void load() override;
void save() override;
private:
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
};
#endif // QT_PROJECT_WIZARD_CONTENT_PATH_SETTINGS_MAVEN_H
@@ -61,6 +61,7 @@ std::vector<FilePath> QtProjectWizardContentPathSourceMaven::getFilePaths() cons
{
{
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath mavenSettingsPath = m_settings->getMavenSettingsFilePathExpandedAndAbsolute();
const FilePath mavenProjectRoot =
m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
@@ -80,7 +81,8 @@ std::vector<FilePath> QtProjectWizardContentPathSourceMaven::getFilePaths() cons
dialogView->showUnknownProgressDialog(
L"Preparing Project", L"Maven\nGenerating Source Files");
const std::wstring errorMessage = utility::mavenGenerateSources(mavenPath, mavenProjectRoot);
const std::wstring errorMessage = utility::mavenGenerateSources(
mavenPath, mavenSettingsPath, mavenProjectRoot);
if (!errorMessage.empty())
{
MessageStatus(errorMessage, true, false).dispatch();