forked from qt-creator/qt-creator
Android: Move logic to trigger AndroidManager::updateGradleProperties
Previously, AndroidManager::updateGradleProperties operated always on a project node found using target->activeRunConfiguration() which might or might not be the one that will actually be used after the build. This here still does not address the problem that the activeRunConfiguration may change but introduces a way to specify the relevant node, and tries to use the right one when available. At some time, this could be developed into a real solution, e.g. by invalidating the cache on build key changes. Change-Id: I37a3d73e9ad3615025e4def2493f683d11add3c6 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
@@ -510,7 +510,6 @@ QString AndroidBuildApkStep::buildTargetSdk() const
|
|||||||
void AndroidBuildApkStep::setBuildTargetSdk(const QString &sdk)
|
void AndroidBuildApkStep::setBuildTargetSdk(const QString &sdk)
|
||||||
{
|
{
|
||||||
m_buildTargetSdk = sdk;
|
m_buildTargetSdk = sdk;
|
||||||
AndroidManager::updateGradleProperties(target());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant AndroidBuildApkStep::data(Core::Id id) const
|
QVariant AndroidBuildApkStep::data(Core::Id id) const
|
||||||
|
@@ -104,6 +104,7 @@ QWidget *AndroidBuildApkWidget::createApplicationGroup()
|
|||||||
connect(targetSDKComboBox, cbActivated, this, [this, targetSDKComboBox](int idx) {
|
connect(targetSDKComboBox, cbActivated, this, [this, targetSDKComboBox](int idx) {
|
||||||
const QString sdk = targetSDKComboBox->itemText(idx);
|
const QString sdk = targetSDKComboBox->itemText(idx);
|
||||||
m_step->setBuildTargetSdk(sdk);
|
m_step->setBuildTargetSdk(sdk);
|
||||||
|
AndroidManager::updateGradleProperties(step()->target(), QString()); // FIXME: Use real key.
|
||||||
});
|
});
|
||||||
|
|
||||||
auto hbox = new QHBoxLayout(group);
|
auto hbox = new QHBoxLayout(group);
|
||||||
|
@@ -683,13 +683,22 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target)
|
bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target, const QString &buildKey)
|
||||||
{
|
{
|
||||||
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||||
if (!version)
|
if (!version)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const ProjectNode *node = currentProjectNode(target);
|
QString key = buildKey;
|
||||||
|
if (key.isEmpty()) {
|
||||||
|
// FIXME: This case is triggered from AndroidBuildApkWidget::createApplicationGroup
|
||||||
|
// and should be avoided.
|
||||||
|
if (RunConfiguration *rc = target->activeRunConfiguration())
|
||||||
|
key = rc->buildKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
QTC_ASSERT(!key.isEmpty(), return false);
|
||||||
|
const ProjectNode *node = target->project()->findNodeForBuildKey(key);
|
||||||
if (!node)
|
if (!node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@@ -117,7 +117,7 @@ public:
|
|||||||
static bool checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd);
|
static bool checkCertificatePassword(const QString &keystorePath, const QString &keystorePasswd, const QString &alias, const QString &certificatePasswd);
|
||||||
static bool checkCertificateExists(const QString &keystorePath, const QString &keystorePasswd,
|
static bool checkCertificateExists(const QString &keystorePath, const QString &keystorePasswd,
|
||||||
const QString &alias);
|
const QString &alias);
|
||||||
static bool updateGradleProperties(ProjectExplorer::Target *target);
|
static bool updateGradleProperties(ProjectExplorer::Target *target, const QString &buildKey);
|
||||||
static int findApiLevel(const Utils::FilePath &platformPath);
|
static int findApiLevel(const Utils::FilePath &platformPath);
|
||||||
|
|
||||||
static QProcess *runAdbCommandDetached(const QStringList &args, QString *err = nullptr,
|
static QProcess *runAdbCommandDetached(const QStringList &args, QString *err = nullptr,
|
||||||
|
@@ -98,34 +98,6 @@ public:
|
|||||||
class AndroidPluginPrivate : public QObject
|
class AndroidPluginPrivate : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AndroidPluginPrivate()
|
|
||||||
{
|
|
||||||
connect(SessionManager::instance(), &SessionManager::projectAdded, this, [=](Project *project) {
|
|
||||||
for (Target *target : project->targets())
|
|
||||||
handleNewTarget(target);
|
|
||||||
connect(project, &Project::addedTarget, this, &AndroidPluginPrivate::handleNewTarget);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleNewTarget(Target *target)
|
|
||||||
{
|
|
||||||
if (DeviceTypeKitAspect::deviceTypeId(target->kit()) != Android::Constants::ANDROID_DEVICE_TYPE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (BuildConfiguration *bc : target->buildConfigurations())
|
|
||||||
handleNewBuildConfiguration(bc);
|
|
||||||
|
|
||||||
connect(target, &Target::addedBuildConfiguration,
|
|
||||||
this, &AndroidPluginPrivate::handleNewBuildConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleNewBuildConfiguration(BuildConfiguration *bc)
|
|
||||||
{
|
|
||||||
connect(bc->target()->project(), &Project::parsingFinished, bc, [bc] {
|
|
||||||
AndroidManager::updateGradleProperties(bc->target());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
AndroidConfigurations androidConfiguration;
|
AndroidConfigurations androidConfiguration;
|
||||||
AndroidSettingsPage settingsPage;
|
AndroidSettingsPage settingsPage;
|
||||||
AndroidDeployQtStepFactory deployQtStepFactory;
|
AndroidDeployQtStepFactory deployQtStepFactory;
|
||||||
|
@@ -134,6 +134,7 @@ AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id)
|
|||||||
|
|
||||||
connect(target->project(), &Project::parsingFinished, this, [this] {
|
connect(target->project(), &Project::parsingFinished, this, [this] {
|
||||||
updateTargetInformation();
|
updateTargetInformation();
|
||||||
|
AndroidManager::updateGradleProperties(this->target(), buildKey());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -343,7 +343,7 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
|
|||||||
nullptr, [this, &addedFiles](QFileInfo src, QFileInfo dst, QString *){return copy(src, dst, &addedFiles);});
|
nullptr, [this, &addedFiles](QFileInfo src, QFileInfo dst, QString *){return copy(src, dst, &addedFiles);});
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidManager::updateGradleProperties(m_target);
|
AndroidManager::updateGradleProperties(m_target, m_buildKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user