Skip to content

Commit 387c7c0

Browse files
authored
feat: --gradlePath argument support (#5628)
1 parent 42d1487 commit 387c7c0

14 files changed

+42
-16
lines changed

lib/commands/plugin/build-plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class BuildPluginCommand implements ICommand {
5252
);
5353

5454
const options: IPluginBuildOptions = {
55+
gradlePath: this.$options.gradlePath,
5556
aarOutputDir: platformsAndroidPath,
5657
platformsAndroidDirPath: platformsAndroidPath,
5758
pluginName: pluginName,

lib/data/build-data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class AndroidBuildData extends BuildData {
4747
public keyStoreAliasPassword: string;
4848
public keyStorePassword: string;
4949
public androidBundle: boolean;
50+
public gradlePath: string;
5051

5152
constructor(projectDir: string, platform: string, data: any) {
5253
super(projectDir, platform, data);
@@ -56,5 +57,6 @@ export class AndroidBuildData extends BuildData {
5657
this.keyStoreAliasPassword = data.keyStoreAliasPassword;
5758
this.keyStorePassword = data.keyStorePassword;
5859
this.androidBundle = data.androidBundle || data.aab;
60+
this.gradlePath = data.gradlePath;
5961
}
6062
}

lib/declarations.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ interface IAndroidBundleOptions {
579579
aab: boolean;
580580
}
581581

582+
interface IAndroidOptions {
583+
gradlePath: string;
584+
}
585+
582586
interface ITypingsOptions {
583587
jar: string;
584588
aar: string;
@@ -598,6 +602,7 @@ interface IOptions
598602
IClean,
599603
IProvision,
600604
ITeamIdentifier,
605+
IAndroidOptions,
601606
IAndroidReleaseOptions,
602607
IAndroidBundleOptions,
603608
INpmInstallConfigurationOptions,

lib/definitions/android-plugin-migrator.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface IAndroidBuildOptions {
1010
pluginName: string;
1111
aarOutputDir: string;
1212
tempPluginDirPath: string;
13+
gradlePath?: string;
1314
}
1415

1516
interface IAndroidPluginBuildService {
@@ -37,4 +38,9 @@ interface IBuildAndroidPluginData extends Partial<IProjectDir> {
3738
* Information about tools that will be used to build the plugin, for example compile SDK version, build tools version, etc.
3839
*/
3940
androidToolsInfo?: IAndroidToolsInfoData;
41+
42+
/**
43+
* Optional custom Gradle path.
44+
*/
45+
gradlePath?: string;
4046
}

lib/definitions/build.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ interface IiOSBuildData extends IBuildData {
2929
interface IAndroidBuildData
3030
extends IBuildData,
3131
IAndroidSigningData,
32-
IHasAndroidBundle {}
32+
IHasAndroidBundle {
33+
gradlePath?: string;
34+
}
3335

3436
interface IAndroidSigningData {
3537
keyStoreAlias: string;

lib/definitions/gradle.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface IGradleCommandOptions {
1313
message?: string;
1414
stdio?: string;
1515
spawnOptions?: ISpawnFromEventOptions;
16+
gradlePath?: string;
1617
}
1718

1819
interface IGradleBuildService {

lib/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export class Options {
215215
default: false,
216216
hasSensitiveValue: false,
217217
},
218+
gradlePath: { type: OptionType.String, hasSensitiveValue: false },
218219
aab: { type: OptionType.Boolean, hasSensitiveValue: false },
219220
performance: { type: OptionType.Object, hasSensitiveValue: true },
220221
appleApplicationSpecificPassword: {

lib/services/android-plugin-build-service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
260260
options.projectDir
261261
);
262262
await this.buildPlugin({
263+
gradlePath: options.gradlePath,
263264
pluginDir: pluginTempDir,
264265
pluginName: options.pluginName,
265266
projectDir: options.projectDir,
@@ -715,7 +716,9 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
715716
);
716717
}
717718

718-
const gradlew = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew";
719+
const gradlew =
720+
pluginBuildSettings.gradlePath ??
721+
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");
719722

720723
const localArgs = [
721724
"-p",

lib/services/android-project-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
6161
$fs: IFileSystem,
6262
private $logger: ILogger,
6363
$projectDataService: IProjectDataService,
64+
private $options: IOptions,
6465
private $injector: IInjector,
6566
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
6667
private $androidPluginBuildService: IAndroidPluginBuildService,
@@ -603,6 +604,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
603604
);
604605
if (this.$fs.exists(pluginPlatformsFolderPath)) {
605606
const options: IPluginBuildOptions = {
607+
gradlePath: this.$options.gradlePath,
606608
projectDir: projectData.projectDir,
607609
pluginName: pluginData.name,
608610
platformsAndroidDirPath: pluginPlatformsFolderPath,

lib/services/android/gradle-build-service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class GradleBuildService
3636
cwd: projectRoot,
3737
message: "Gradle build...",
3838
stdio: buildData.buildOutputStdio,
39+
gradlePath: buildData.gradlePath,
3940
spawnOptions,
4041
};
4142

@@ -60,6 +61,7 @@ export class GradleBuildService
6061
const gradleCommandOptions = {
6162
cwd: projectRoot,
6263
message: "Gradle clean...",
64+
gradlePath: buildData.gradlePath,
6365
};
6466
await this.$gradleCommandService.executeCommand(
6567
cleanTaskArgs,

0 commit comments

Comments
 (0)