This commit is contained in:
committed by
Eberhard Graether
parent
32136c5d78
commit
21c07cf5bf
@@ -35,13 +35,30 @@ void SourceGroupSettingsWithJavaMaven::setShouldIndexMavenTests(bool value)
|
||||
m_shouldIndexMavenTests = value;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsWithJavaMaven::getMavenSettingsFilePath() const
|
||||
{
|
||||
return m_mavenSettingsFilePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsWithJavaMaven::getMavenSettingsFilePathExpandedAndAbsolute() const
|
||||
{
|
||||
return utility::getExpandedAndAbsolutePath(
|
||||
getMavenSettingsFilePath(), getProjectSettings()->getProjectDirectoryPath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsWithJavaMaven::setMavenSettingsFilePath(const FilePath& path)
|
||||
{
|
||||
m_mavenSettingsFilePath = path;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsWithJavaMaven::equals(const SourceGroupSettingsBase* other) const
|
||||
{
|
||||
const SourceGroupSettingsWithJavaMaven* otherPtr =
|
||||
dynamic_cast<const SourceGroupSettingsWithJavaMaven*>(other);
|
||||
|
||||
return (
|
||||
otherPtr && m_mavenProjectFilePath == otherPtr->m_mavenProjectFilePath &&
|
||||
otherPtr && m_mavenProjectFilePath == otherPtr->m_mavenProjectFilePath && otherPtr &&
|
||||
m_mavenSettingsFilePath == otherPtr->m_mavenSettingsFilePath &&
|
||||
m_shouldIndexMavenTests == otherPtr->m_shouldIndexMavenTests);
|
||||
}
|
||||
|
||||
@@ -49,11 +66,14 @@ void SourceGroupSettingsWithJavaMaven::load(const ConfigManager* config, const s
|
||||
{
|
||||
setMavenProjectFilePath(
|
||||
config->getValueOrDefault(key + "/maven/project_file_path", FilePath(L"")));
|
||||
setMavenSettingsFilePath(
|
||||
config->getValueOrDefault(key + "/maven/settings_file_path", FilePath(L"")));
|
||||
setShouldIndexMavenTests(config->getValueOrDefault(key + "/maven/should_index_tests", false));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsWithJavaMaven::save(ConfigManager* config, const std::string& key)
|
||||
{
|
||||
config->setValue(key + "/maven/project_file_path", getMavenProjectFilePath().wstr());
|
||||
config->setValue(key + "/maven/settings_file_path", getMavenSettingsFilePath().wstr());
|
||||
config->setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ public:
|
||||
bool getShouldIndexMavenTests() const;
|
||||
void setShouldIndexMavenTests(bool value);
|
||||
|
||||
FilePath getMavenSettingsFilePath() const;
|
||||
FilePath getMavenSettingsFilePathExpandedAndAbsolute() const;
|
||||
void setMavenSettingsFilePath(const FilePath& path);
|
||||
|
||||
protected:
|
||||
bool equals(const SourceGroupSettingsBase* other) const override;
|
||||
|
||||
@@ -27,6 +31,7 @@ protected:
|
||||
private:
|
||||
FilePath m_mavenProjectFilePath;
|
||||
bool m_shouldIndexMavenTests = false;
|
||||
FilePath m_mavenSettingsFilePath;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_WITH_JAVA_MAVEN_H
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
{
|
||||
|
||||
+52
@@ -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
|
||||
+3
-1
@@ -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();
|
||||
|
||||
@@ -73,6 +73,7 @@ bool SourceGroupJavaMaven::prepareMavenData()
|
||||
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath mavenSettingsPath = m_settings->getMavenSettingsFilePathExpandedAndAbsolute();
|
||||
const FilePath projectRootPath =
|
||||
m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
|
||||
@@ -83,7 +84,8 @@ bool SourceGroupJavaMaven::prepareMavenData()
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView]() { dialogView->hideUnknownProgressDialog(); });
|
||||
|
||||
const std::wstring errorMessage = utility::mavenGenerateSources(mavenPath, projectRootPath);
|
||||
const std::wstring errorMessage = utility::mavenGenerateSources(
|
||||
mavenPath, mavenSettingsPath, projectRootPath);
|
||||
if (!errorMessage.empty())
|
||||
{
|
||||
MessageStatus(errorMessage, true, false).dispatch();
|
||||
@@ -95,7 +97,10 @@ bool SourceGroupJavaMaven::prepareMavenData()
|
||||
L"Preparing Project", L"Maven\nExporting Dependencies");
|
||||
|
||||
bool success = utility::mavenCopyDependencies(
|
||||
mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryPath());
|
||||
mavenPath,
|
||||
mavenSettingsPath,
|
||||
projectRootPath,
|
||||
m_settings->getMavenDependenciesDirectoryPath());
|
||||
|
||||
return success;
|
||||
}
|
||||
@@ -114,11 +119,13 @@ std::vector<FilePath> SourceGroupJavaMaven::doGetAllSourcePaths() const
|
||||
L"Preparing Project", L"Maven\nFetching Source Directories");
|
||||
|
||||
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
|
||||
const FilePath mavenSettingsPath = m_settings->getMavenSettingsFilePathExpandedAndAbsolute();
|
||||
const FilePath projectRootPath =
|
||||
m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory();
|
||||
|
||||
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(
|
||||
mavenPath,
|
||||
mavenSettingsPath,
|
||||
projectRootPath,
|
||||
m_settings->getMavenDependenciesDirectoryPath(),
|
||||
m_settings->getShouldIndexMavenTests());
|
||||
|
||||
@@ -81,17 +81,37 @@ std::wstring getErrorMessageFromMavenOutput(std::shared_ptr<const TextAccess> ma
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
std::string getMavenArgsString(const FilePath& settingsFilePath)
|
||||
{
|
||||
std::vector<std::string> args;
|
||||
if (!settingsFilePath.empty() && settingsFilePath.exists())
|
||||
{
|
||||
args.push_back("--settings \"" + settingsFilePath.str() + "\"");
|
||||
}
|
||||
std::string ret = "";
|
||||
for (const std::string& arg: args)
|
||||
{
|
||||
ret += arg + " ";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::wstring mavenGenerateSources(const FilePath& mavenPath, const FilePath& projectDirectoryPath)
|
||||
std::wstring mavenGenerateSources(
|
||||
const FilePath& mavenPath, const FilePath& settingsFilePath, const FilePath& projectDirectoryPath)
|
||||
{
|
||||
utility::setJavaHomeVariableIfNotExists();
|
||||
|
||||
std::shared_ptr<TextAccess> outputAccess = TextAccess::createFromString(
|
||||
utility::executeProcessUntilNoOutput(
|
||||
"\"" + mavenPath.str() + "\" generate-sources", projectDirectoryPath, 60000));
|
||||
"\"" + mavenPath.str() + "\" " + getMavenArgsString(settingsFilePath) + "generate-sources",
|
||||
projectDirectoryPath,
|
||||
60000));
|
||||
|
||||
if (outputAccess->isEmpty())
|
||||
{
|
||||
@@ -103,14 +123,17 @@ std::wstring mavenGenerateSources(const FilePath& mavenPath, const FilePath& pro
|
||||
}
|
||||
|
||||
bool mavenCopyDependencies(
|
||||
const FilePath& mavenPath, const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath)
|
||||
const FilePath& mavenPath,
|
||||
const FilePath& settingsFilePath,
|
||||
const FilePath& projectDirectoryPath,
|
||||
const FilePath& outputDirectoryPath)
|
||||
{
|
||||
utility::setJavaHomeVariableIfNotExists();
|
||||
|
||||
std::shared_ptr<TextAccess> outputAccess = TextAccess::createFromString(
|
||||
utility::executeProcessUntilNoOutput(
|
||||
"\"" + mavenPath.str() +
|
||||
"\" dependency:copy-dependencies -DoutputDirectory=" + outputDirectoryPath.str(),
|
||||
"\"" + mavenPath.str() + "\" " + getMavenArgsString(settingsFilePath) +
|
||||
"dependency:copy-dependencies -DoutputDirectory=" + outputDirectoryPath.str(),
|
||||
projectDirectoryPath,
|
||||
60000));
|
||||
|
||||
@@ -127,6 +150,7 @@ bool mavenCopyDependencies(
|
||||
|
||||
std::vector<FilePath> mavenGetAllDirectoriesFromEffectivePom(
|
||||
const FilePath& mavenPath,
|
||||
const FilePath& settingsFilePath,
|
||||
const FilePath& projectDirectoryPath,
|
||||
const FilePath& outputDirectoryPath,
|
||||
bool addTestDirectories)
|
||||
@@ -137,7 +161,8 @@ std::vector<FilePath> mavenGetAllDirectoriesFromEffectivePom(
|
||||
|
||||
std::shared_ptr<TextAccess> outputAccess = TextAccess::createFromString(
|
||||
utility::executeProcessUntilNoOutput(
|
||||
"\"" + mavenPath.str() + "\" help:effective-pom -Doutput=\"" + outputPath.str(),
|
||||
"\"" + mavenPath.str() + "\" " + getMavenArgsString(settingsFilePath) +
|
||||
"help:effective-pom -Doutput=\"" + outputPath.str(),
|
||||
projectDirectoryPath,
|
||||
60000));
|
||||
|
||||
|
||||
@@ -8,13 +8,16 @@ class FilePath;
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::wstring mavenGenerateSources(const FilePath& mavenPath, const FilePath& projectDirectoryPath);
|
||||
std::wstring mavenGenerateSources(
|
||||
const FilePath& mavenPath, const FilePath& settingsFilePath, const FilePath& projectDirectoryPath);
|
||||
bool mavenCopyDependencies(
|
||||
const FilePath& mavenPath,
|
||||
const FilePath& settingsFilePath,
|
||||
const FilePath& projectDirectoryPath,
|
||||
const FilePath& outputDirectoryPath);
|
||||
std::vector<FilePath> mavenGetAllDirectoriesFromEffectivePom(
|
||||
const FilePath& mavenPath,
|
||||
const FilePath& settingsFilePath,
|
||||
const FilePath& projectDirectoryPath,
|
||||
const FilePath& outputDirectoryPath,
|
||||
bool addTestDirectories);
|
||||
|
||||
Reference in New Issue
Block a user