This commit is contained in:
@@ -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