build_apk.dart 1.62 KB
Newer Older
1 2 3 4 5 6
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

7
import '../android/apk.dart';
8 9
import '../base/file_system.dart';
import '../project.dart';
10
import 'build.dart';
11

12
class BuildApkCommand extends BuildSubCommand {
13
  BuildApkCommand({bool verboseHelp = false}) {
14
    usesTargetOption();
15
    addBuildModeFlags();
16
    usesFlavorOption();
17
    usesPubOption();
18 19
    usesBuildNumberOption();
    usesBuildNameOption();
20 21

    argParser
22 23 24 25 26
      ..addFlag('preview-dart-2',
        defaultsTo: true,
        hide: !verboseHelp,
        help: 'Preview Dart 2.0 functionality.',
      )
27
      ..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp)
28
      ..addFlag('build-shared-library',
29 30 31
        negatable: false,
        help: 'Whether to prefer compiling to a *.so file (android only).',
      )
32 33 34
      ..addOption('target-platform',
        defaultsTo: 'android-arm',
        allowed: <String>['android-arm', 'android-arm64']);
35 36
  }

37 38 39 40
  @override
  final String name = 'apk';

  @override
41
  final String description = 'Build an Android APK file from your app.\n\n'
42 43
    'This command can build debug and release versions of your application. \'debug\' builds support\n'
    'debugging and a quick development cycle. \'release\' builds don\'t support debugging and are\n'
44
    'suitable for deploying to app stores.';
45

46
  @override
47
  Future<Null> runCommand() async {
48
    await super.runCommand();
49
    await buildApk(project: new FlutterProject(fs.currentDirectory),target: targetFile, buildInfo: getBuildInfo());
50
  }
51
}