run method

  1. @override
void run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
void run() async {
  CucumberHelper.removeNdjsonGherkin();
  final argTarget = argResults.getOptionTarget();
  final argFlavor = argResults.getOptionFlavor(defaultTo: Constants.dev);
  final argMorphemeYaml = argResults.getOptionMorphemeYaml();
  final argBuildNumber = argResults.getOptionBuildNumber();
  final argBuildName = argResults.getOptionBuildName();
  final argObfuscate = argResults.getFlagObfuscate();
  final argSplitDebugInfo = argResults.getOptionSplitDebugInfo();
  final argGenerateL10n = argResults.getFlagGenerateL10n();

  YamlHelper.validateMorphemeYaml(argMorphemeYaml);

  if (argGenerateL10n) {
    await 'morpheme l10n --morpheme-yaml "$argMorphemeYaml"'.run;
  }

  final flavor = FlavorHelper.byFlavor(argFlavor, argMorphemeYaml);

  FirebaseHelper.run(argFlavor, argMorphemeYaml);

  List<String> dartDefines = [];
  flavor.forEach((key, value) {
    dartDefines.add('${Constants.dartDefine} "$key=$value"');
  });
  final mode = argResults.getMode();

  await FlutterHelper.run(
    'build apk -t $argTarget ${dartDefines.join(' ')} $mode $argBuildNumber $argBuildName $argObfuscate $argSplitDebugInfo',
    showLog: true,
  );

  StatusHelper.success('build apk');
}