Commit 6ff12968 authored by BogDan Vatra's avatar BogDan Vatra

Android: update gradle wrapper properties

We need to call it when QmakeProject emits proFilesEvaluated to be sure
AndroidPackageSourceDir is set.

Task-number: QTCREATORBUG-15568
Change-Id: Ia70e0cff1b5fb8f2003ba2c2799a694873b2ad19
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
parent 4c16632f
......@@ -700,9 +700,21 @@ bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target)
AndroidBuildApkStep *buildApkStep
= AndroidGlobal::buildStep<AndroidBuildApkStep>(target->activeBuildConfiguration());
if (!buildApkStep || !buildApkStep->androidPackageSourceDir().appendPath(QLatin1String("gradlew")).exists())
if (!buildApkStep || !buildApkStep->useGradle() || !buildApkStep->androidPackageSourceDir().appendPath(QLatin1String("gradlew")).exists())
return false;
Utils::FileName wrapperProps(buildApkStep->androidPackageSourceDir());
wrapperProps.appendPath(QLatin1String("gradle/wrapper/gradle-wrapper.properties"));
if (wrapperProps.exists()) {
GradleProperties wrapperProperties = readGradleProperties(wrapperProps.toString());
QString distributionUrl = QString::fromLocal8Bit(wrapperProperties["distributionUrl"]);
QRegExp re(QLatin1String(".*services.gradle.org/distributions/gradle-2..*.zip"));
if (!re.exactMatch(distributionUrl)) {
wrapperProperties["distributionUrl"] = "https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip";
mergeGradleProperties(wrapperProps.toString(), wrapperProperties);
}
}
GradleProperties localProperties;
localProperties["sdk.dir"] = AndroidConfigurations::currentConfig().sdkLocation().toString().toLocal8Bit();
if (!mergeGradleProperties(buildApkStep->androidPackageSourceDir().appendPath(QLatin1String("local.properties")).toString(), localProperties))
......
......@@ -39,8 +39,10 @@
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qmakeprojectmanager/qmakebuildinfo.h>
#include <qmakeprojectmanager/qmakeproject.h>
using namespace QmakeAndroidSupport::Internal;
......@@ -96,7 +98,16 @@ ProjectExplorer::BuildConfiguration *AndroidQmakeBuildConfigurationFactory::rest
AndroidQmakeBuildConfiguration::AndroidQmakeBuildConfiguration(ProjectExplorer::Target *target)
: QmakeProjectManager::QmakeBuildConfiguration(target)
{
using QmakeProjectManager::QmakeProject;
auto updateGrade = [this] {
Android::AndroidManager::updateGradleProperties(BuildConfiguration::target());
};
QmakeProject *project = qobject_cast<QmakeProject *>(target->project());
if (project)
connect(project, &QmakeProject::proFilesEvaluated, this, updateGrade);
else
connect(this, &AndroidQmakeBuildConfiguration::enabledChanged, this, updateGrade);
}
AndroidQmakeBuildConfiguration::AndroidQmakeBuildConfiguration(ProjectExplorer::Target *target, AndroidQmakeBuildConfiguration *source)
......
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