Skip to content

Commit

Permalink
feat: --gradlePath argument support (#5628)
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Feb 15, 2022
1 parent 42d1487 commit 387c7c0
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/commands/plugin/build-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class BuildPluginCommand implements ICommand {
);

const options: IPluginBuildOptions = {
gradlePath: this.$options.gradlePath,
aarOutputDir: platformsAndroidPath,
platformsAndroidDirPath: platformsAndroidPath,
pluginName: pluginName,
Expand Down
2 changes: 2 additions & 0 deletions lib/data/build-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class AndroidBuildData extends BuildData {
public keyStoreAliasPassword: string;
public keyStorePassword: string;
public androidBundle: boolean;
public gradlePath: string;

constructor(projectDir: string, platform: string, data: any) {
super(projectDir, platform, data);
Expand All @@ -56,5 +57,6 @@ export class AndroidBuildData extends BuildData {
this.keyStoreAliasPassword = data.keyStoreAliasPassword;
this.keyStorePassword = data.keyStorePassword;
this.androidBundle = data.androidBundle || data.aab;
this.gradlePath = data.gradlePath;
}
}
5 changes: 5 additions & 0 deletions lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ interface IAndroidBundleOptions {
aab: boolean;
}

interface IAndroidOptions {
gradlePath: string;
}

interface ITypingsOptions {
jar: string;
aar: string;
Expand All @@ -598,6 +602,7 @@ interface IOptions
IClean,
IProvision,
ITeamIdentifier,
IAndroidOptions,
IAndroidReleaseOptions,
IAndroidBundleOptions,
INpmInstallConfigurationOptions,
Expand Down
6 changes: 6 additions & 0 deletions lib/definitions/android-plugin-migrator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface IAndroidBuildOptions {
pluginName: string;
aarOutputDir: string;
tempPluginDirPath: string;
gradlePath?: string;
}

interface IAndroidPluginBuildService {
Expand Down Expand Up @@ -37,4 +38,9 @@ interface IBuildAndroidPluginData extends Partial<IProjectDir> {
* Information about tools that will be used to build the plugin, for example compile SDK version, build tools version, etc.
*/
androidToolsInfo?: IAndroidToolsInfoData;

/**
* Optional custom Gradle path.
*/
gradlePath?: string;
}
4 changes: 3 additions & 1 deletion lib/definitions/build.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ interface IiOSBuildData extends IBuildData {
interface IAndroidBuildData
extends IBuildData,
IAndroidSigningData,
IHasAndroidBundle {}
IHasAndroidBundle {
gradlePath?: string;
}

interface IAndroidSigningData {
keyStoreAlias: string;
Expand Down
1 change: 1 addition & 0 deletions lib/definitions/gradle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface IGradleCommandOptions {
message?: string;
stdio?: string;
spawnOptions?: ISpawnFromEventOptions;
gradlePath?: string;
}

interface IGradleBuildService {
Expand Down
1 change: 1 addition & 0 deletions lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ export class Options {
default: false,
hasSensitiveValue: false,
},
gradlePath: { type: OptionType.String, hasSensitiveValue: false },
aab: { type: OptionType.Boolean, hasSensitiveValue: false },
performance: { type: OptionType.Object, hasSensitiveValue: true },
appleApplicationSpecificPassword: {
Expand Down
5 changes: 4 additions & 1 deletion lib/services/android-plugin-build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
options.projectDir
);
await this.buildPlugin({
gradlePath: options.gradlePath,
pluginDir: pluginTempDir,
pluginName: options.pluginName,
projectDir: options.projectDir,
Expand Down Expand Up @@ -715,7 +716,9 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
);
}

const gradlew = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew";
const gradlew =
pluginBuildSettings.gradlePath ??
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");

const localArgs = [
"-p",
Expand Down
2 changes: 2 additions & 0 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
$fs: IFileSystem,
private $logger: ILogger,
$projectDataService: IProjectDataService,
private $options: IOptions,
private $injector: IInjector,
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $androidPluginBuildService: IAndroidPluginBuildService,
Expand Down Expand Up @@ -603,6 +604,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
);
if (this.$fs.exists(pluginPlatformsFolderPath)) {
const options: IPluginBuildOptions = {
gradlePath: this.$options.gradlePath,
projectDir: projectData.projectDir,
pluginName: pluginData.name,
platformsAndroidDirPath: pluginPlatformsFolderPath,
Expand Down
2 changes: 2 additions & 0 deletions lib/services/android/gradle-build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class GradleBuildService
cwd: projectRoot,
message: "Gradle build...",
stdio: buildData.buildOutputStdio,
gradlePath: buildData.gradlePath,
spawnOptions,
};

Expand All @@ -60,6 +61,7 @@ export class GradleBuildService
const gradleCommandOptions = {
cwd: projectRoot,
message: "Gradle clean...",
gradlePath: buildData.gradlePath,
};
await this.$gradleCommandService.executeCommand(
cleanTaskArgs,
Expand Down
6 changes: 3 additions & 3 deletions lib/services/android/gradle-command-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class GradleCommandService implements IGradleCommandService {
this.$logger.info(message);

const childProcessOptions = { cwd, stdio: stdio || "inherit" };
const gradleExecutable = this.$hostInfo.isWindows
? "gradlew.bat"
: "./gradlew";
const gradleExecutable =
options.gradlePath ??
(this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew");

const result = await this.executeCommandSafe(
gradleExecutable,
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const createTestInjector = (): IInjector => {
testInjector.register("androidPluginBuildService", {});
testInjector.register("errors", stubs.ErrorsStub);
testInjector.register("logger", stubs.LoggerStub);
testInjector.register("options", {});
testInjector.register("projectData", stubs.ProjectDataStub);
testInjector.register("androidToolsInfo", {
getToolsInfo: () => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3607,10 +3607,10 @@
"plist" "^2.0.1"
"yargs" "^6.5.0"

"ios-sim-portable@4.2.4":
"integrity" "sha512-TqgrBp3omXkKwXEHVpLxo3+uJqi6XTLdXpL/YGlXdQ0fL7RYySmqkVQcc98vea/eQMpR9ImTGxyAsKerW/819A=="
"resolved" "https://registry.npmjs.org/ios-sim-portable/-/ios-sim-portable-4.2.4.tgz"
"version" "4.2.4"
"ios-sim-portable@4.2.5":
"integrity" "sha512-2xuE60u+cjSwDoj3rXeN7PbuVtCDTZUhY5vkWWjlJj/TlWuLJMFEx9lgr5OGuYv7jRldpqD/nwGhtOdM2llKHw=="
"resolved" "https://registry.npmjs.org/ios-sim-portable/-/ios-sim-portable-4.2.5.tgz"
"version" "4.2.5"
dependencies:
"bplist-parser" "https://github.com/telerik/node-bplist-parser/tarball/master"
"colors" "~1.4.0"
Expand Down

0 comments on commit 387c7c0

Please sign in to comment.