forked from qt-creator/qt-creator
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: Tobias Hunger <tobias.hunger@theqtcompany.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
This commit is contained in:
@@ -700,9 +700,21 @@ bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target)
|
|||||||
AndroidBuildApkStep *buildApkStep
|
AndroidBuildApkStep *buildApkStep
|
||||||
= AndroidGlobal::buildStep<AndroidBuildApkStep>(target->activeBuildConfiguration());
|
= 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;
|
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;
|
GradleProperties localProperties;
|
||||||
localProperties["sdk.dir"] = AndroidConfigurations::currentConfig().sdkLocation().toString().toLocal8Bit();
|
localProperties["sdk.dir"] = AndroidConfigurations::currentConfig().sdkLocation().toString().toLocal8Bit();
|
||||||
if (!mergeGradleProperties(buildApkStep->androidPackageSourceDir().appendPath(QLatin1String("local.properties")).toString(), localProperties))
|
if (!mergeGradleProperties(buildApkStep->androidPackageSourceDir().appendPath(QLatin1String("local.properties")).toString(), localProperties))
|
||||||
|
@@ -39,8 +39,10 @@
|
|||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <qmakeprojectmanager/qmakebuildinfo.h>
|
#include <qmakeprojectmanager/qmakebuildinfo.h>
|
||||||
|
#include <qmakeprojectmanager/qmakeproject.h>
|
||||||
|
|
||||||
using namespace QmakeAndroidSupport::Internal;
|
using namespace QmakeAndroidSupport::Internal;
|
||||||
|
|
||||||
@@ -96,7 +98,16 @@ ProjectExplorer::BuildConfiguration *AndroidQmakeBuildConfigurationFactory::rest
|
|||||||
AndroidQmakeBuildConfiguration::AndroidQmakeBuildConfiguration(ProjectExplorer::Target *target)
|
AndroidQmakeBuildConfiguration::AndroidQmakeBuildConfiguration(ProjectExplorer::Target *target)
|
||||||
: QmakeProjectManager::QmakeBuildConfiguration(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)
|
AndroidQmakeBuildConfiguration::AndroidQmakeBuildConfiguration(ProjectExplorer::Target *target, AndroidQmakeBuildConfiguration *source)
|
||||||
|
Reference in New Issue
Block a user