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 @@
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/environment.h>
#include <QDateTime>
#include <QSettings>
......@@ -733,6 +734,15 @@ void AndroidConfigurations::load()
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
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();
}
......
......@@ -278,6 +278,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished()
return;
}
m_androidConfig.sdkLocation = location;
searchForAnt(location.toString());
saveSettings(true);
m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices());
m_ui->AVDManagerFrame->setEnabled(true);
......@@ -289,9 +290,28 @@ void AndroidSettingsWidget::ndkLocationEditingFinished()
m_androidConfig.toolchainHost.clear(); // force toolchain host detection
if (!checkNDK(location))
return;
searchForAnt(location.toString());
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()
{
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text());
......
......@@ -75,6 +75,7 @@ public:
private slots:
void sdkLocationEditingFinished();
void ndkLocationEditingFinished();
void searchForAnt(const QString &location);
void antLocationEditingFinished();
void openJDKLocationEditingFinished();
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