Skip to content

Commit

Permalink
feat(cli): Add support for Android build --flavor (#6437)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Anderson <[email protected]>
  • Loading branch information
theproducer and markemer authored Mar 27, 2023
1 parent 82f7c60 commit e91a8e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cli/src/android/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export async function buildAndroid(
): Promise<void> {
const releaseType = buildOptions.androidreleasetype ?? 'AAB';
const releaseTypeIsAAB = releaseType === 'AAB';
const arg = releaseTypeIsAAB ? ':app:bundleRelease' : 'assembleRelease';
const flavor = buildOptions.flavor ?? '';
const arg = releaseTypeIsAAB
? `:app:bundle${flavor}Release`
: `assemble${flavor}Release`;
const gradleArgs = [arg];

if (
Expand Down Expand Up @@ -46,7 +49,7 @@ export async function buildAndroid(
'build',
'outputs',
releaseTypeIsAAB ? 'bundle' : 'apk',
'release',
buildOptions.flavor ? `${flavor}Release` : 'release',
);

const unsignedReleaseName = `app${
Expand Down
1 change: 1 addition & 0 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export function runProgram(config: Config): void {
.command('build <platform>')
.description('builds the release version of the selected platform')
.option('--scheme <schemeToBuild>', 'iOS Scheme to build')
.option('--flavor <flavorToBuild>', 'Android Flavor to build')
.option('--keystorepath <keystorePath>', 'Path to the keystore')
.option('--keystorepass <keystorePass>', 'Password to the keystore')
.option('--keystorealias <keystoreAlias>', 'Key Alias in the keystore')
Expand Down
2 changes: 2 additions & 0 deletions cli/src/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { buildiOS } from '../ios/build';

export interface BuildCommandOptions {
scheme?: string;
flavor?: string;
keystorepath?: string;
keystorepass?: string;
keystorealias?: string;
Expand All @@ -31,6 +32,7 @@ export async function buildCommand(

const buildCommandOptions: BuildCommandOptions = {
scheme: buildOptions.scheme || config.ios.scheme,
flavor: buildOptions.flavor || config.android.flavor,
keystorepath:
buildOptions.keystorepath || config.android.buildOptions.keystorePath,
keystorepass:
Expand Down

0 comments on commit e91a8e7

Please sign in to comment.