Commit d340d26e authored by Daniel Teske's avatar Daniel Teske

Android: ant auto detection

Change-Id: I3afaab99c8e71a6dabe6d61ed55247a1cecc2d45
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 37cd957a
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <utils/environment.h>
#include <QDateTime> #include <QDateTime>
#include <QSettings> #include <QSettings>
...@@ -733,6 +734,15 @@ void AndroidConfigurations::load() ...@@ -733,6 +734,15 @@ void AndroidConfigurations::load()
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup); settings->beginGroup(SettingsGroup);
m_config = AndroidConfig(*settings); m_config = AndroidConfig(*settings);
if (m_config.antLocation.isEmpty()) {
Utils::Environment env = Utils::Environment::systemEnvironment();
QString location = env.searchInPath(QLatin1String("ant"));
QFileInfo fi(location);
if (fi.exists() && fi.isExecutable() && !fi.isDir())
m_config.antLocation = Utils::FileName::fromString(location);
}
settings->endGroup(); settings->endGroup();
} }
......
...@@ -278,6 +278,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished() ...@@ -278,6 +278,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished()
return; return;
} }
m_androidConfig.sdkLocation = location; m_androidConfig.sdkLocation = location;
searchForAnt(location.toString());
saveSettings(true); saveSettings(true);
m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices()); m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices());
m_ui->AVDManagerFrame->setEnabled(true); m_ui->AVDManagerFrame->setEnabled(true);
...@@ -289,9 +290,28 @@ void AndroidSettingsWidget::ndkLocationEditingFinished() ...@@ -289,9 +290,28 @@ void AndroidSettingsWidget::ndkLocationEditingFinished()
m_androidConfig.toolchainHost.clear(); // force toolchain host detection m_androidConfig.toolchainHost.clear(); // force toolchain host detection
if (!checkNDK(location)) if (!checkNDK(location))
return; return;
searchForAnt(location.toString());
saveSettings(true); saveSettings(true);
} }
void AndroidSettingsWidget::searchForAnt(const QString &location)
{
if (!m_androidConfig.antLocation.isEmpty())
return;
if (location.isEmpty())
return;
QDir parentFolder = QFileInfo(location).absoluteDir();
foreach (const QString &file, parentFolder.entryList()) {
if (file.startsWith(QLatin1String("apache-ant"))) {
QString ant = parentFolder.absolutePath() + QLatin1Char('/') + file + QLatin1String("/bin/ant.bat");
if (QFileInfo(ant).exists()) {
m_androidConfig.antLocation = Utils::FileName::fromString(ant);
m_ui->AntLocationLineEdit->setText(ant);
}
}
}
}
void AndroidSettingsWidget::antLocationEditingFinished() void AndroidSettingsWidget::antLocationEditingFinished()
{ {
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text()); Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text());
......
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
private slots: private slots:
void sdkLocationEditingFinished(); void sdkLocationEditingFinished();
void ndkLocationEditingFinished(); void ndkLocationEditingFinished();
void searchForAnt(const QString &location);
void antLocationEditingFinished(); void antLocationEditingFinished();
void openJDKLocationEditingFinished(); void openJDKLocationEditingFinished();
void browseSDKLocation(); void browseSDKLocation();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment