Android: Move CreateAndroidManifestWizard and related build step to base

It does not directly depend on qmake anymore.

Change-Id: I3b9625e54d98c79ef137059cf4554b3f2807e88e
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
hjk
2018-07-02 18:40:29 +02:00
parent 5807cea413
commit 6aeb06c8d3
17 changed files with 74 additions and 172 deletions

View File

@@ -54,7 +54,8 @@ HEADERS += \
androidsdkmodel.h \ androidsdkmodel.h \
androidsdkmanagerwidget.h \ androidsdkmanagerwidget.h \
androidpackageinstallationstep.h \ androidpackageinstallationstep.h \
androidextralibrarylistmodel.h androidextralibrarylistmodel.h \
createandroidmanifestwizard.h
SOURCES += \ SOURCES += \
androidconfigurations.cpp \ androidconfigurations.cpp \
@@ -102,7 +103,8 @@ SOURCES += \
androidsdkmodel.cpp \ androidsdkmodel.cpp \
androidsdkmanagerwidget.cpp \ androidsdkmanagerwidget.cpp \
androidpackageinstallationstep.cpp \ androidpackageinstallationstep.cpp \
androidextralibrarylistmodel.cpp androidextralibrarylistmodel.cpp \
createandroidmanifestwizard.cpp
FORMS += \ FORMS += \
androidsettingswidget.ui \ androidsettingswidget.ui \

View File

@@ -116,6 +116,8 @@ Project {
"avddialog.h", "avddialog.h",
"certificatesmodel.cpp", "certificatesmodel.cpp",
"certificatesmodel.h", "certificatesmodel.h",
"createandroidmanifestwizard.h",
"createandroidmanifestwizard.cpp",
"javaeditor.cpp", "javaeditor.cpp",
"javaeditor.h", "javaeditor.h",
"javaindenter.cpp", "javaindenter.cpp",

View File

@@ -25,6 +25,7 @@
****************************************************************************/ ****************************************************************************/
#include "androidbuildapkstep.h" #include "androidbuildapkstep.h"
#include "androidbuildapkwidget.h" #include "androidbuildapkwidget.h"
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include "androidconstants.h" #include "androidconstants.h"
@@ -40,6 +41,7 @@
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
@@ -48,6 +50,8 @@
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
@@ -61,12 +65,15 @@
#include <memory> #include <memory>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Android::Internal;
namespace { namespace {
Q_LOGGING_CATEGORY(buildapkstepLog, "qtc.android.build.androidbuildapkstep") Q_LOGGING_CATEGORY(buildapkstepLog, "qtc.android.build.androidbuildapkstep")
} }
namespace Android { namespace Android {
using namespace Internal;
const Core::Id ANDROID_BUILD_APK_ID("QmakeProjectManager.AndroidBuildApkStep");
const QVersionNumber gradleScriptRevokedSdkVersion(25, 3, 0); const QVersionNumber gradleScriptRevokedSdkVersion(25, 3, 0);
const char KeystoreLocationKey[] = "KeystoreLocation"; const char KeystoreLocationKey[] = "KeystoreLocation";
@@ -115,8 +122,8 @@ private:
this); this);
}; };
AndroidBuildApkStep::AndroidBuildApkStep(ProjectExplorer::BuildStepList *parent, Core::Id id) AndroidBuildApkStep::AndroidBuildApkStep(BuildStepList *parent)
: ProjectExplorer::AbstractProcessStep(parent, id), : AbstractProcessStep(parent, ANDROID_BUILD_APK_ID),
m_buildTargetSdk(AndroidConfig::apiLevelNameFor(AndroidConfigurations:: m_buildTargetSdk(AndroidConfig::apiLevelNameFor(AndroidConfigurations::
sdkManager()->latestAndroidSdkPlatform())) sdkManager()->latestAndroidSdkPlatform()))
{ {
@@ -263,7 +270,7 @@ void AndroidBuildApkStep::showInGraphicalShell()
ProjectExplorer::BuildStepConfigWidget *AndroidBuildApkStep::createConfigWidget() ProjectExplorer::BuildStepConfigWidget *AndroidBuildApkStep::createConfigWidget()
{ {
return new AndroidBuildApkInnerWidget(this); return new AndroidBuildApkWidget(this);
} }
void AndroidBuildApkStep::processFinished(int exitCode, QProcess::ExitStatus status) void AndroidBuildApkStep::processFinished(int exitCode, QProcess::ExitStatus status)
@@ -537,6 +544,22 @@ QString PasswordInputDialog::getPassword(Context context, std::function<bool (co
return isAccepted ? dlg->inputEdit->text() : ""; return isAccepted ? dlg->inputEdit->text() : "";
} }
namespace Internal {
// AndroidBuildApkStepFactory
AndroidBuildApkStepFactory::AndroidBuildApkStepFactory()
{
registerStep<AndroidBuildApkStep>(ANDROID_BUILD_APK_ID);
setSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
setDisplayName(AndroidBuildApkStep::tr("Build Android APK"));
setRepeatable(false);
}
} // namespace Internal
} // namespace Android } // namespace Android
#include "androidbuildapkstep.moc" #include "androidbuildapkstep.moc"

View File

@@ -27,6 +27,7 @@
#pragma once #pragma once
#include "android_global.h" #include "android_global.h"
#include <projectexplorer/abstractprocessstep.h> #include <projectexplorer/abstractprocessstep.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -39,10 +40,9 @@ class ANDROID_EXPORT AndroidBuildApkStep : public ProjectExplorer::AbstractProce
{ {
Q_OBJECT Q_OBJECT
protected:
AndroidBuildApkStep(ProjectExplorer::BuildStepList *bc, Core::Id id);
public: public:
AndroidBuildApkStep(ProjectExplorer::BuildStepList *bc);
bool fromMap(const QVariantMap &map) override; bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override; QVariantMap toMap() const override;
@@ -104,4 +104,13 @@ private:
bool m_skipBuilding = false; bool m_skipBuilding = false;
}; };
namespace Internal {
class AndroidBuildApkStepFactory : public ProjectExplorer::BuildStepFactory
{
public:
AndroidBuildApkStepFactory();
};
} // namespace Internal
} // namespace Android } // namespace Android

View File

@@ -30,11 +30,9 @@
#include "androidcreatekeystorecertificate.h" #include "androidcreatekeystorecertificate.h"
#include "androidmanager.h" #include "androidmanager.h"
#include "androidsdkmanager.h" #include "androidsdkmanager.h"
#include "createandroidmanifestwizard.h"
#include "ui_androidbuildapkwidget.h" #include "ui_androidbuildapkwidget.h"
#include <android/androidbuildapkwidget.h>
#include <android/androidmanager.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
@@ -55,10 +53,8 @@
#include <algorithm> #include <algorithm>
using namespace Android;
using namespace Internal;
namespace Android { namespace Android {
namespace Internal {
const int minApiSupported = 9; const int minApiSupported = 9;
@@ -240,7 +236,7 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step) :
{ {
m_extraLibraryListModel = new AndroidExtraLibraryListModel(m_step->target(), this); m_extraLibraryListModel = new AndroidExtraLibraryListModel(m_step->target(), this);
auto base = new Android::AndroidBuildApkInnerWidget(step); auto base = new AndroidBuildApkInnerWidget(step);
base->layout()->setContentsMargins(0, 0, 0, 0); base->layout()->setContentsMargins(0, 0, 0, 0);
auto createTemplatesGroupBox = new QGroupBox(tr("Android")); auto createTemplatesGroupBox = new QGroupBox(tr("Android"));
@@ -284,8 +280,10 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step) :
topLayout->addWidget(createTemplatesGroupBox); topLayout->addWidget(createTemplatesGroupBox);
topLayout->addWidget(additionalLibrariesGroupBox); topLayout->addWidget(additionalLibrariesGroupBox);
connect(createAndroidTemplatesButton, &QAbstractButton::clicked, connect(createAndroidTemplatesButton, &QAbstractButton::clicked, this, [this] {
this, &AndroidBuildApkWidget::requestAndroidTemplates); CreateAndroidManifestWizard wizard(m_step->target());
wizard.exec();
});
connect(addAndroidExtraLibButton, &QAbstractButton::clicked, connect(addAndroidExtraLibButton, &QAbstractButton::clicked,
this, &AndroidBuildApkWidget::addAndroidExtraLib); this, &AndroidBuildApkWidget::addAndroidExtraLib);
@@ -336,4 +334,5 @@ QString AndroidBuildApkWidget::displayName() const
return summaryText(); return summaryText();
} }
} // Internal
} // Android } // Android

View File

@@ -42,10 +42,9 @@ namespace Ui { class AndroidBuildApkWidget; }
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Android { namespace Android {
namespace Internal {
class AndroidBuildApkStep; class AndroidBuildApkInnerWidget : public ProjectExplorer::BuildStepConfigWidget
class ANDROID_EXPORT AndroidBuildApkInnerWidget : public ProjectExplorer::BuildStepConfigWidget
{ {
Q_OBJECT Q_OBJECT
@@ -72,12 +71,12 @@ private:
AndroidBuildApkStep *m_step; AndroidBuildApkStep *m_step;
}; };
class ANDROID_EXPORT AndroidBuildApkWidget : public ProjectExplorer::BuildStepConfigWidget class AndroidBuildApkWidget : public ProjectExplorer::BuildStepConfigWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AndroidBuildApkWidget(Android::AndroidBuildApkStep *step); explicit AndroidBuildApkWidget(AndroidBuildApkStep *step);
signals: signals:
void requestAndroidTemplates(); void requestAndroidTemplates();
@@ -94,9 +93,10 @@ private:
QListView *m_androidExtraLibsListView = nullptr; QListView *m_androidExtraLibsListView = nullptr;
QToolButton *m_removeAndroidExtraLibButton = nullptr; QToolButton *m_removeAndroidExtraLibButton = nullptr;
Android::AndroidBuildApkStep *m_step = nullptr; AndroidBuildApkStep *m_step = nullptr;
Android::AndroidExtraLibraryListModel *m_extraLibraryListModel = nullptr; Android::AndroidExtraLibraryListModel *m_extraLibraryListModel = nullptr;
bool m_ignoreChange = false; bool m_ignoreChange = false;
}; };
} // namespace Internal
} // namespace Android } // namespace Android

View File

@@ -92,6 +92,7 @@ public:
AndroidPackageInstallationFactory packackeInstallationFactory; AndroidPackageInstallationFactory packackeInstallationFactory;
AndroidManifestEditorFactory manifestEditorFactory; AndroidManifestEditorFactory manifestEditorFactory;
AndroidRunConfigurationFactory runConfigFactory; AndroidRunConfigurationFactory runConfigFactory;
AndroidBuildApkStepFactory buildApkStepFactory;
}; };
AndroidPlugin::~AndroidPlugin() AndroidPlugin::~AndroidPlugin()

View File

@@ -30,6 +30,8 @@
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
using namespace Android::Internal;
Utils::FileName Android::AndroidQtSupport::apkPath(const ProjectExplorer::Target *target) const Utils::FileName Android::AndroidQtSupport::apkPath(const ProjectExplorer::Target *target) const
{ {
if (!target) if (!target)

View File

@@ -47,11 +47,11 @@
#include <QMessageBox> #include <QMessageBox>
#include <QVBoxLayout> #include <QVBoxLayout>
using namespace Android;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace QmakeAndroidSupport::Internal;
using namespace Utils; using namespace Utils;
namespace Android {
// //
// NoApplicationProFilePage // NoApplicationProFilePage
// //
@@ -375,3 +375,5 @@ void CreateAndroidManifestWizard::accept()
createAndroidTemplateFiles(); createAndroidTemplateFiles();
Wizard::accept(); Wizard::accept();
} }
} // namespace Android

View File

@@ -25,6 +25,8 @@
#pragma once #pragma once
#include "android_global.h"
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/wizard.h> #include <utils/wizard.h>
@@ -37,8 +39,7 @@ QT_END_NAMESPACE
namespace ProjectExplorer { class Target; } namespace ProjectExplorer { class Target; }
namespace QmakeAndroidSupport { namespace Android {
namespace Internal {
class CreateAndroidManifestWizard; class CreateAndroidManifestWizard;
@@ -84,7 +85,7 @@ private:
bool m_complete; bool m_complete;
}; };
class CreateAndroidManifestWizard : public Utils::Wizard class ANDROID_EXPORT CreateAndroidManifestWizard : public Utils::Wizard
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -118,5 +119,4 @@ private:
bool m_copyGradle; bool m_copyGradle;
}; };
} //namespace QmakeAndroidSupport } // namespace Android
} //namespace Internal

View File

@@ -24,8 +24,8 @@
****************************************************************************/ ****************************************************************************/
#include "androidqmakebuildconfigurationfactory.h" #include "androidqmakebuildconfigurationfactory.h"
#include "qmakeandroidbuildapkstep.h"
#include <android/androidbuildapkstep.h>
#include <android/androidconfigurations.h> #include <android/androidconfigurations.h>
#include <android/androidconstants.h> #include <android/androidconstants.h>
#include <android/androidmanager.h> #include <android/androidmanager.h>
@@ -71,7 +71,7 @@ void AndroidQmakeBuildConfiguration::initialize(const BuildInfo *info)
BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
buildSteps->appendStep(new AndroidPackageInstallationStep(buildSteps)); buildSteps->appendStep(new AndroidPackageInstallationStep(buildSteps));
buildSteps->appendStep(new QmakeAndroidBuildApkStep(buildSteps)); buildSteps->appendStep(new Android::AndroidBuildApkStep(buildSteps));
updateCacheAndEmitEnvironmentChanged(); updateCacheAndEmitEnvironmentChanged();
} }

View File

@@ -1,77 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qmakeandroidbuildapkstep.h"
#include "createandroidmanifestwizard.h"
#include <android/androidconstants.h>
#include <android/androidbuildapkwidget.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
using namespace Android;
namespace QmakeAndroidSupport {
namespace Internal {
const Core::Id ANDROID_BUILD_APK_ID("QmakeProjectManager.AndroidBuildApkStep");
// QmakeAndroidBuildApkStepFactory
QmakeAndroidBuildApkStepFactory::QmakeAndroidBuildApkStepFactory()
{
registerStep<QmakeAndroidBuildApkStep>(ANDROID_BUILD_APK_ID);
setSupportedProjectType(QmakeProjectManager::Constants::QMAKEPROJECT_ID);
setSupportedDeviceType(Constants::ANDROID_DEVICE_TYPE);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
setDisplayName(QmakeAndroidBuildApkStep::tr("Build Android APK"));
setRepeatable(false);
}
// QmakeAndroidBuildApkStep
QmakeAndroidBuildApkStep::QmakeAndroidBuildApkStep(ProjectExplorer::BuildStepList *bc)
: AndroidBuildApkStep(bc, ANDROID_BUILD_APK_ID)
{
}
ProjectExplorer::BuildStepConfigWidget *QmakeAndroidBuildApkStep::createConfigWidget()
{
auto widget = new AndroidBuildApkWidget(this);
connect(widget, &AndroidBuildApkWidget::requestAndroidTemplates, this, [this] {
CreateAndroidManifestWizard wizard(target());
wizard.exec();
});
return widget;
}
} // namespace Internal
} // namespace QmakeAndroidSupport

View File

@@ -1,51 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <android/androidbuildapkstep.h>
namespace QmakeAndroidSupport {
namespace Internal {
class QmakeAndroidBuildApkStepFactory : public ProjectExplorer::BuildStepFactory
{
public:
QmakeAndroidBuildApkStepFactory();
};
class QmakeAndroidBuildApkStep : public Android::AndroidBuildApkStep
{
Q_OBJECT
public:
QmakeAndroidBuildApkStep(ProjectExplorer::BuildStepList *bc);
protected:
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
};
} // namespace Internal
} // namespace QmakeAndroidSupport

View File

@@ -23,10 +23,10 @@
** **
****************************************************************************/ ****************************************************************************/
#include "qmakeandroidbuildapkstep.h"
#include "qmakeandroidsupport.h" #include "qmakeandroidsupport.h"
#include "androidqmakebuildconfigurationfactory.h" #include "androidqmakebuildconfigurationfactory.h"
#include <android/androidbuildapkstep.h>
#include <android/androidconstants.h> #include <android/androidconstants.h>
#include <android/androidglobal.h> #include <android/androidglobal.h>

View File

@@ -5,15 +5,11 @@ DEFINES += \
QMAKEANDROID_LIBRARY QMAKEANDROID_LIBRARY
HEADERS += \ HEADERS += \
createandroidmanifestwizard.h \
qmakeandroidsupport.h \ qmakeandroidsupport.h \
qmakeandroidbuildapkstep.h \
androidqmakebuildconfigurationfactory.h \ androidqmakebuildconfigurationfactory.h \
qmakeandroidsupportplugin.h qmakeandroidsupportplugin.h
SOURCES += \ SOURCES += \
createandroidmanifestwizard.cpp \
qmakeandroidsupport.cpp \ qmakeandroidsupport.cpp \
qmakeandroidbuildapkstep.cpp \
androidqmakebuildconfigurationfactory.cpp \ androidqmakebuildconfigurationfactory.cpp \
qmakeandroidsupportplugin.cpp qmakeandroidsupportplugin.cpp

View File

@@ -16,10 +16,6 @@ QtcPlugin {
Depends { name: "Qt.widgets" } Depends { name: "Qt.widgets" }
files: [ files: [
"createandroidmanifestwizard.cpp",
"createandroidmanifestwizard.h",
"qmakeandroidbuildapkstep.cpp",
"qmakeandroidbuildapkstep.h",
"androidqmakebuildconfigurationfactory.cpp", "androidqmakebuildconfigurationfactory.cpp",
"androidqmakebuildconfigurationfactory.h", "androidqmakebuildconfigurationfactory.h",
"qmakeandroidsupport.cpp", "qmakeandroidsupport.cpp",

View File

@@ -26,7 +26,6 @@
#include "qmakeandroidsupportplugin.h" #include "qmakeandroidsupportplugin.h"
#include "androidqmakebuildconfigurationfactory.h" #include "androidqmakebuildconfigurationfactory.h"
#include "qmakeandroidbuildapkstep.h"
#include "qmakeandroidsupport.h" #include "qmakeandroidsupport.h"
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -38,7 +37,6 @@ class QmakeAndroidSupportPluginPrivate
{ {
public: public:
AndroidQmakeBuildConfigurationFactory buildConfigFactory; AndroidQmakeBuildConfigurationFactory buildConfigFactory;
QmakeAndroidBuildApkStepFactory buildApkStepFactory;
QmakeAndroidSupport androidSupport; QmakeAndroidSupport androidSupport;
}; };