Skip to content
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

feat(cli): add apksigner as a build option #6442

Merged
merged 22 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions cli/src/android/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ export async function buildAndroid(
: `assemble${flavor}Release`;
const gradleArgs = [arg];

if (
!buildOptions.keystorepath ||
!buildOptions.keystorealias ||
!buildOptions.keystorealiaspass ||
!buildOptions.keystorepass
) {
throw 'Missing options. Please supply all options for android signing. (Keystore Path, Keystore Password, Keystore Key Alias, Keystore Key Password)';
if (!buildOptions.keystorepath || !buildOptions.keystorepass) {
throw 'Missing options. Please supply all options for android signing. (Keystore Path, Keystore Password)';
}

try {
Expand Down Expand Up @@ -64,24 +59,19 @@ export async function buildAndroid(
);

const signingArgs = [
'-sigalg',
'SHA1withRSA',
'-digestalg',
'SHA1',
'-keystore',
'sign',
'--ks',
buildOptions.keystorepath,
'-keypass',
buildOptions.keystorealiaspass,
'-storepass',
buildOptions.keystorepass,
`-signedjar`,
`${join(releasePath, signedReleaseName)}`,
'--ks-pass',
`pass:${buildOptions.keystorepass}`,
'--in',
`${join(releasePath, unsignedReleaseName)}`,
buildOptions.keystorealias,
'--out',
`${join(releasePath, signedReleaseName)}`,
];

await runTask('Signing Release', async () => {
await runCommand('jarsigner', signingArgs, {
await runCommand('apksigner', signingArgs, {
cwd: config.android.platformDirAbs,
});
});
Expand Down
3 changes: 0 additions & 3 deletions cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,6 @@ async function loadAndroidConfig(
const buildOptions = {
keystorePath: extConfig.android?.buildOptions?.keystorePath,
keystorePassword: extConfig.android?.buildOptions?.keystorePassword,
keystoreAlias: extConfig.android?.buildOptions?.keystoreAlias,
keystoreAliasPassword:
extConfig.android?.buildOptions?.keystoreAliasPassword,

Choose a reason for hiding this comment

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

It's mistake, return pls))

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, so I created a pull request to correct it, but still not merged yet. 😞

releaseType: extConfig.android?.buildOptions?.releaseType,
};

Expand Down
14 changes: 0 additions & 14 deletions cli/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,6 @@ export interface CapacitorConfig {
*/
keystorePassword?: string;

/**
* Alias in the keystore to use
*
* @since 4.4.0
*/
keystoreAlias?: string;

/**
* Password for the alias in the keystore to use
*
* @since 4.4.0
*/
keystoreAliasPassword?: string;

/**
* Bundle type for your release build
*
Expand Down
2 changes: 0 additions & 2 deletions cli/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ export interface AndroidConfig extends PlatformConfig {
readonly buildOptions: {
keystorePath?: string;
keystorePassword?: string;
keystoreAlias?: string;
keystoreAliasPassword?: string;
releaseType?: 'AAB' | 'APK';
};
}
Expand Down
16 changes: 1 addition & 15 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ export function runProgram(config: Config): void {
.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')
.option(
'--keystorealiaspass <keystoreAliasPass>',
'Password for the Key Alias',
)
.addOption(
new Option(
'--androidreleasetype <androidreleasetype>',
Expand All @@ -161,22 +156,13 @@ export function runProgram(config: Config): void {
config,
async (
platform,
{
scheme,
keystorepath,
keystorepass,
keystorealias,
keystorealiaspass,
androidreleasetype,
},
{ scheme, keystorepath, keystorepass, androidreleasetype },
) => {
const { buildCommand } = await import('./tasks/build');
await buildCommand(config, platform, {
scheme,
keystorepath,
keystorepass,
keystorealias,
keystorealiaspass,
androidreleasetype,
});
},
Expand Down
7 changes: 0 additions & 7 deletions cli/src/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export interface BuildCommandOptions {
flavor?: string;
keystorepath?: string;
keystorepass?: string;
keystorealias?: string;
keystorealiaspass?: string;
androidreleasetype?: 'AAB' | 'APK';
}

Expand All @@ -37,11 +35,6 @@ export async function buildCommand(
buildOptions.keystorepath || config.android.buildOptions.keystorePath,
keystorepass:
buildOptions.keystorepass || config.android.buildOptions.keystorePassword,
keystorealias:
buildOptions.keystorealias || config.android.buildOptions.keystoreAlias,
keystorealiaspass:
buildOptions.keystorealiaspass ||
config.android.buildOptions.keystoreAliasPassword,
androidreleasetype:
buildOptions.androidreleasetype ||
config.android.buildOptions.releaseType ||
Expand Down