diff options
author | BogDan Vatra <bogdan@kde.org> | 2014-09-22 16:20:51 +0300 |
---|---|---|
committer | BogDan Vatra <bogdan@kde.org> | 2014-09-25 13:15:25 +0200 |
commit | 3bcae5258456577682437c2f09eae7bef59c4c34 (patch) | |
tree | f641b594ac52d876d7f9ef51431f65e71828d5e8 /src/plugins/android/androidbuildapkstep.cpp | |
parent | 222fbdb58bc08ae54480cec448d1578a55376348 (diff) | |
download | qt-creator-3bcae5258456577682437c2f09eae7bef59c4c34.tar.gz |
Android: Say hello to gradle!
Switching from Ant to Gradle brings lots of advantages:
- it is way faster when rebuilding (25-50% faster than ant).
- it enables first class Android Studio integration.
- adding Android Extras libs (e.g. Google Play services, OBB, etc.) to
your project is now painless.
[ChangeLog][Android] Added Gradle support to build the APK.
Change-Id: Iee492954f8ffb2c22e6ab14a8a25faf644de9a51
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/android/androidbuildapkstep.cpp')
-rw-r--r-- | src/plugins/android/androidbuildapkstep.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index c1b6a4cfcf..fc9ce9eca9 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -59,18 +59,22 @@ const QLatin1String DeployActionKey("Qt4ProjectManager.AndroidDeployQtStep.Deplo const QLatin1String KeystoreLocationKey("KeystoreLocation"); const QLatin1String BuildTargetSdkKey("BuildTargetSdk"); const QLatin1String VerboseOutputKey("VerboseOutput"); +const QLatin1String UseGradleKey("UseGradle"); AndroidBuildApkStep::AndroidBuildApkStep(ProjectExplorer::BuildStepList *parent, const Core::Id id) : ProjectExplorer::AbstractProcessStep(parent, id), m_deployAction(BundleLibrariesDeployment), m_signPackage(false), m_verbose(false), + m_useGradle(false), m_openPackageLocation(false), m_buildTargetSdk(AndroidConfig::apiLevelNameFor(AndroidConfigurations::currentConfig().highestAndroidSdk())) { const QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); - if (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0)) + if (version && version->qtVersion() >= QtSupport::QtVersionNumber(5, 4, 0)) { m_deployAction = DebugDeployment; + m_useGradle = AndroidConfigurations::currentConfig().useGrandle(); + } //: AndroidBuildApkStep default display name setDefaultDisplayName(tr("Build Android APK")); } @@ -81,6 +85,7 @@ AndroidBuildApkStep::AndroidBuildApkStep(ProjectExplorer::BuildStepList *parent, m_deployAction(other->deployAction()), m_signPackage(other->signPackage()), m_verbose(other->m_verbose), + m_useGradle(other->m_useGradle), m_openPackageLocation(other->m_openPackageLocation), m_buildTargetSdk(other->m_buildTargetSdk) { @@ -88,6 +93,8 @@ AndroidBuildApkStep::AndroidBuildApkStep(ProjectExplorer::BuildStepList *parent, if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) { if (m_deployAction == DebugDeployment) m_deployAction = BundleLibrariesDeployment; + if (m_useGradle) + m_useGradle = false; } } @@ -123,8 +130,7 @@ bool AndroidBuildApkStep::init() setOutputParser(parser); m_openPackageLocationForRun = m_openPackageLocation; - m_apkPath = AndroidManager::androidQtSupport(target())->apkPath(target(), m_signPackage ? AndroidQtSupport::ReleaseBuildSigned - : AndroidQtSupport::DebugBuild).toString(); + m_apkPath = AndroidManager::androidQtSupport(target())->apkPath(target()).toString(); bool result = AbstractProcessStep::init(); if (!result) @@ -169,6 +175,7 @@ bool AndroidBuildApkStep::fromMap(const QVariantMap &map) if (m_buildTargetSdk.isEmpty()) m_buildTargetSdk = AndroidConfig::apiLevelNameFor(AndroidConfigurations::currentConfig().highestAndroidSdk()); m_verbose = map.value(VerboseOutputKey).toBool(); + m_useGradle = map.value(UseGradleKey).toBool(); return ProjectExplorer::BuildStep::fromMap(map); } @@ -179,6 +186,7 @@ QVariantMap AndroidBuildApkStep::toMap() const map.insert(KeystoreLocationKey, m_keystorePath.toString()); map.insert(BuildTargetSdkKey, m_buildTargetSdk); map.insert(VerboseOutputKey, m_verbose); + map.insert(UseGradleKey, m_useGradle); return map; } @@ -195,6 +203,8 @@ QString AndroidBuildApkStep::buildTargetSdk() const void AndroidBuildApkStep::setBuildTargetSdk(const QString &sdk) { m_buildTargetSdk = sdk; + if (m_useGradle) + AndroidManager::updateGradleProperties(target()); } AndroidBuildApkStep::AndroidDeployAction AndroidBuildApkStep::deployAction() const @@ -254,6 +264,18 @@ void AndroidBuildApkStep::setVerboseOutput(bool verbose) m_verbose = verbose; } +bool AndroidBuildApkStep::useGradle() const +{ + return m_useGradle; +} + +void AndroidBuildApkStep::setUseGradle(bool b) +{ + m_useGradle = b; + if (m_useGradle) + AndroidManager::updateGradleProperties(target()); +} + bool AndroidBuildApkStep::runInGuiThread() const { return true; |