Skip to content

Support multiple .apk files produced from gradle build #3467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2018

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Mar 16, 2018

This PR adds support for multiple .apk files produced from gradle build in following cases:

  1. When productFlavors are used
    Add this to app/App_Resources/app.gradle file
flavorDimensions "arch", "mode"

  productFlavors {
    demo {
      dimension "mode"
    }
    full {
      dimension "mode"
    }
    x86 {
      dimension "arch"
    }
    arm {
      dimension "arch"
    }
    arm64 {
      dimension "arch"
    }
  }
  1. When splits option is used
    Add this to app/App_Resources/app.gradle file
splits {
    abi {
      enable true //enables the ABIs split mechanism
      reset() //reset the list of ABIs to be included to an empty string
      include 'arm64-v8a', 'armeabi-v7a', 'x86'
      universalApk true
    }
  }

@Fatme
Copy link
Contributor Author

Fatme commented Mar 16, 2018

},
getValidPackageNames: (buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): string[] => {
deviceBuildOutputPath: path.join(...deviceBuildOutputArr),
getValidBuildOutputData: (buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): IValidBuildOutputData => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This { isReleaseBuild?: boolean, isForDevice?: boolean } could be extracted as a separate interface and be reused here and in platform.d.ts

`${projectData.projectName}.apk`,
`app-${buildMode}.apk`
],
regexes: [/app-.*-(debug|release).apk/, new RegExp(`${packageName}-.*-(debug|release).apk`)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can extract apk or .apk to a constant (or use APK_DIR from constants, although I suggest a separate constant for example APK_EXTENSION_NAME) and reuse it in both regexes

In addition, you can use APP_FOLDER_NAME from constants here, as well as the Configurations object from common/constants for getting debug and release constants.

I'd suggest we add the ignore case (i) flag to both regular expressions here just to be on the safe side, too.

`${packageName}-${buildMode}.apk`,
`${projectData.projectName}-${buildMode}.apk`,
`${projectData.projectName}.apk`,
`app-${buildMode}.apk`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can reuse the APP_FOLDER_NAME here

];
return {
packageNames: [
`${packageName}-${buildMode}.apk`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you decide to introduce a constant for .apk you can reuse it here and below

getDeviceBuildOutputPath: (options: IRelease): string => {
return path.join(projectRoot, "build", "device");
},
deviceBuildOutputPath: path.join(projectRoot, "build", "device"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use BUILD_DIR from constants here

emulatorBuildOutputPath: path.join(projectRoot, "build", "emulator"),
getValidPackageNames: (buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): string[] => {
getValidBuildOutputData: (buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): IValidBuildOutputData => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you decide to extract

{ isReleaseBuild?: boolean, isForDevice?: boolean }

to an interface you can reuse it here

}

private getLatestApplicationPackage(buildOutputPath: string, validPackageNames: string[]): IApplicationPackage {
let packages = this.getApplicationPackages(buildOutputPath, validPackageNames);
private createApplicationPackage(filepath: string): IApplicationPackage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method's argument could be named packageName in order to enable a shorter syntax down below:

return {
    packageName,
    time: this.$fs.getFsStats(packageName).mtime
};

}
getValidPackageNames = (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [""];
deviceBuildOutputPath = "";
getValidBuildOutputData = (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => ({ packageNames: [""] });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An interface can be used here as well

test/stubs.ts Outdated
},
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
deviceBuildOutputPath: "",
getValidBuildOutputData: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => ({ packageNames: []}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An interface may be reused here as well

test/stubs.ts Outdated
},
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
deviceBuildOutputPath: "",
getValidBuildOutputData: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => ({ packageNames: [] }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An interface may be reused here as well

@Fatme Fatme force-pushed the fatme/multiple-apks branch from e1b983a to 86ac9bd Compare March 16, 2018 14:32
@dtopuzov
Copy link
Contributor

run ci

2 similar comments
@Fatme
Copy link
Contributor Author

Fatme commented Mar 19, 2018

run ci

@Fatme
Copy link
Contributor Author

Fatme commented Mar 20, 2018

run ci

Copy link
Contributor

@Mitko-Kerezov Mitko-Kerezov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me

@Fatme Fatme merged commit 7ff8a54 into release Mar 20, 2018
@Fatme Fatme deleted the fatme/multiple-apks branch March 20, 2018 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants