Bug 1103121 - Add |mach gradle| command for building Fennec Gradle. r=gps
authorNick Alexander <nalexander@mozilla.com>
Fri, 21 Nov 2014 12:40:00 -0800
changeset 241647 197ddcc3d0bccd8ae6650b9dc9c0462e746a2840
parent 241646 a24ed9776645e1e8c4e7f1f46d5f3e3bcf6ea633
child 241648 a5c944be6248aa7b361d80196de09312b6f8fe36
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1103121
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1103121 - Add |mach gradle| command for building Fennec Gradle. r=gps I went with gradle instead of gradlew because it's more likely to be what users consider. And mach helpfully fixes up the uncommon typo. This is a little hard-coded right now but I don't think it's likely any other Gradle consumer will arise in the short term.
build/mach_bootstrap.py
mobile/android/base/docs/gradle.rst
mobile/android/mach_commands.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -83,16 +83,17 @@ MACH_MODULES = [
     'testing/mochitest/mach_commands.py',
     'testing/xpcshell/mach_commands.py',
     'testing/talos/mach_commands.py',
     'testing/web-platform/mach_commands.py',
     'testing/xpcshell/mach_commands.py',
     'tools/docs/mach_commands.py',
     'tools/mercurial/mach_commands.py',
     'tools/mach_commands.py',
+    'mobile/android/mach_commands.py',
 ]
 
 
 CATEGORIES = {
     'build': {
         'short': 'Build Commands',
         'long': 'Interact with the build system',
         'priority': 80,
--- a/mobile/android/base/docs/gradle.rst
+++ b/mobile/android/base/docs/gradle.rst
@@ -5,18 +5,17 @@
 ======================
 
 Instructions
 ============
 
 .. code-block:: shell
 
   ./mach build && ./mach package
-  cd $OBJDIR/mobile/android
-  ./gradlew build
+  ./mach gradle build
 
 The debug APK will be at
 ``$OBJDIR/mobile/android/gradle/app/build/outputs/apk/app-debug.apk``.
 
 The ``$OBJDIR/mobile/android/gradle`` directory can be imported into IntelliJ as
 follows:
 
 - File > Import Project
new file mode 100644
--- /dev/null
+++ b/mobile/android/mach_commands.py
@@ -0,0 +1,36 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import print_function, unicode_literals
+
+import argparse
+import logging
+import mozpack.path as mozpath
+
+from mozbuild.base import (
+    MachCommandBase,
+    MachCommandConditions as conditions,
+)
+
+from mach.decorators import (
+    CommandArgument,
+    CommandProvider,
+    Command,
+)
+
+
+@CommandProvider
+class MachCommands(MachCommandBase):
+    @Command('gradle', category='devenv',
+        description='Run gradle.',
+        conditions=[conditions.is_android])
+    @CommandArgument('args', nargs=argparse.REMAINDER)
+    def gradle(self, args):
+        # Avoid logging the command
+        self.log_manager.terminal_handler.setLevel(logging.CRITICAL)
+
+        return self.run_process(['./gradlew'] + args,
+            pass_thru=True, # Allow user to run gradle interactively.
+            ensure_exit_code=False, # Don't throw on non-zero exit code.
+            cwd=mozpath.join(self.topobjdir, 'mobile', 'android', 'gradle'))