Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
build:android - allow for passing custom gradle args (#239)
Browse files Browse the repository at this point in the history
* build:android - allow for passing custom gradle args

* update CHANGELOG

* upgrade @expo/xdl to 57.9.25-alpha.1
  • Loading branch information
dsokal authored Jul 15, 2020
1 parent 0803811 commit fbabcdf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- `--gradle-args` option for `turtle build:android` which makes it possible to specify custom Gradle arguments.

### Changed

- Gradle Wrapper doesn't print when dots when the appropriate version of Gradle is being downloaded.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"dependencies": {
"@expo/config": "^3.2.14",
"@expo/spawn-async": "^1.4.2",
"@expo/xdl": "57.9.25-alpha.0",
"@expo/xdl": "57.9.25-alpha.1",
"@google-cloud/logging-bunyan": "^2.0.3",
"async-retry": "^1.2.1",
"aws-sdk": "^2.226.1",
Expand Down
5 changes: 5 additions & 0 deletions src/bin/commands/build/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default (program: any, setCommonCommandOptions: any) => {
/^(debug|release)$/i,
'release',
)
.option(
'--gradle-args <gradle-args>',
'optional arguments passed to gradle, make sure to surround them with double quotes'
+ ' (e.g.: --gradle-args "--stacktrace --debug")',
)
.description(
'Build a standalone APK or App Bundle for your project, either signed and ready for submission to'
+ ' the Google Play Store or in debug mode.',
Expand Down
10 changes: 6 additions & 4 deletions src/bin/utils/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function createBuilderAction({
await setup(platform, sdkVersion);
const credentials = await prepareCredentials(cmd);
const rawJob = {
...await buildJobObject(platform, projectConfig, args, credentials, sdkVersion),
...await buildJobObject(cmd, platform, projectConfig, args, credentials, sdkVersion),
...cmd.buildDir && { fakeUploadDir: ProjectUtils.resolveAbsoluteDir(cmd.buildDir) },
...cmd.output && { fakeUploadBuildPath: ProjectUtils.resolveAbsoluteDir(cmd.output) },
};
Expand Down Expand Up @@ -113,6 +113,7 @@ function getExpoSDKVersionSafely(projectDir: string, projectConfig: ProjectConfi
}

const buildJobObject = async (
cmd: any,
platform: 'android' | 'ios',
projectConfig: ProjectConfig,
{ releaseChannel, buildType, buildMode, username, publicUrl, projectDir }: any,
Expand All @@ -125,11 +126,12 @@ const buildJobObject = async (
config: {
...(projectConfig.exp?.[platform]?.config || {}),
buildType,
...(platform === 'android' ? { buildMode } : {}),
releaseChannel,
...(platform === 'ios' ? { bundleIdentifier: projectConfig.exp?.ios?.bundleIdentifier } : {}),
...(platform === 'android' ? { androidPackage: projectConfig.exp?.android?.package } : {}),
publicUrl,
...(platform === 'android' && cmd.gradleArgs ? { gradleArgs: cmd.gradleArgs.split(' ') } : {}),
...(platform === 'android' ? { buildMode } : {}),
...(platform === 'android' ? { androidPackage: projectConfig.exp?.android?.package } : {}),
...(platform === 'ios' ? { bundleIdentifier: projectConfig.exp?.ios?.bundleIdentifier } : {}),
},
id: uuid.v4(),
platform,
Expand Down
5 changes: 3 additions & 2 deletions src/builders/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default async function buildAndroid(jobData: IJob): Promise<IJobResult> {
...config.builder.fakeUpload && {
fakeUploadBuildPath:
jobData.fakeUploadBuildPath
? jobData.fakeUploadBuildPath
: path.join(jobData.fakeUploadDir || config.directories.fakeUploadDir, fakeUploadFilename),
? jobData.fakeUploadBuildPath
: path.join(jobData.fakeUploadDir || config.directories.fakeUploadDir, fakeUploadFilename),
},
});

Expand Down Expand Up @@ -103,6 +103,7 @@ async function runShellAppBuilder(
modules: enabledModules,
buildType: jobData.config.buildType,
buildMode: jobData.config.buildMode,
gradleArgs: jobData.config.gradleArgs,
});
} catch (err) {
commonUtils.logErrorOnce(err);
Expand Down
1 change: 1 addition & 0 deletions src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface IJob {
// android
androidPackage?: string;
buildMode?: ANDROID_BUILD_MODES;
gradleArgs?: string[];
};
credentials: {
// android
Expand Down
1 change: 1 addition & 0 deletions src/jobsSchemas/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default baseJobSchema.concat(
config: Joi.object().keys({
buildMode: Joi.string().valid(Object.values(ANDROID_BUILD_MODES)).default(ANDROID_BUILD_MODES.RELEASE),
buildType: Joi.string().valid(Object.values(ANDROID_BUILD_TYPES)).default(ANDROID_BUILD_TYPES.APK),
gradleArgs: Joi.array().items(Joi.string()),
}),
}),
);
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2064,10 +2064,10 @@
workbox-webpack-plugin "^3.6.3"
worker-loader "^2.0.0"

"@expo/[email protected].0":
version "57.9.25-alpha.0"
resolved "https://registry.yarnpkg.com/@expo/xdl/-/xdl-57.9.25-alpha.0.tgz#b5ecebea4ac9e567d25a0eb3dcfadb6a2405568a"
integrity sha512-Fvxga0DbS/qZVym2yUSg3Kf1tn2FpFqDbYi5M/yk7gZNMQITh6Ssv1Jib+WTpSL7cDR3M+GOAS7GuIy12Db+Iw==
"@expo/[email protected].1":
version "57.9.25-alpha.1"
resolved "https://registry.yarnpkg.com/@expo/xdl/-/xdl-57.9.25-alpha.1.tgz#1c96219b10f8214b9db623044d7e613c83b7bf25"
integrity sha512-EEsbxZUnwQVpsvZfcoLeVuI9e1R4bZpXXYU9Rx50PeahvBRzhFSYtZd5LBKcfhlQn6IhCNQU2JTyhYJGlJB6mw==
dependencies:
"@expo/bunyan" "3.0.2"
"@expo/config" "3.2.15"
Expand Down

0 comments on commit fbabcdf

Please sign in to comment.