question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow gradle options to be passed to build

See original GitHub issue

Describe the Feature

It would be great if we could include options for the gradle build command, or overwrite them completely

Here is the related source https://github.com/react-native-community/cli/blob/master/packages/platform-android/src/commands/runAndroid/index.ts#L204

This would allow me to disable tests for the build for example

Possible Implementations

function buildApk(gradlew: string, sourceDir: string, replacementGradleBuildArgs: string = undefined) {
  try {
    // using '-x lint' in order to ignore linting errors while building the apk
    const gradleBuildArgs = replacementGradleBuildArgs || ['-x', 'lint'].join(' ');
    const gradleArgs = ['build', gradleBuildArgs];
    logger.info('Building the app...');
    logger.debug(`Running command "${gradlew} ${gradleArgs.join(' ')}"`);
    execa.sync(gradlew, gradleArgs, {stdio: 'inherit', cwd: sourceDir});
  } catch (error) {
    throw new CLIError('Failed to build the app.', error);
  }
}
buildApk(gradlew, androidProject.sourceDir, args.gradleBuildArgs);

Usage:

yarn android --gradleBuildArgs="-x lint -x test"

I would expect to see in the logs:

Running command gradle build -x lint - x test

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
adamTrzcommented, Nov 28, 2022

There’s ongoing effort to add custom gradle options with #1729

0reactions
github-actions[bot]commented, Nov 27, 2022

There hasn’t been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command-Line Interface - Gradle User Manual
Executing Gradle on the command-line conforms to the following structure. Options are allowed before and after task names. gradle [taskName...] [--option-name..
Read more >
Passing Command Line Arguments in Gradle - Baeldung
When we want to pass input arguments from the Gradle CLI, we have two choices: setting system properties with the -D flag; setting...
Read more >
Command-line options | Gradle Effective Implementation Guide
The gradle command is used to execute a build. This command accepts several command-line options. We know the option --quiet (or -q )...
Read more >
Gradle tips and recipes - Android Developers
If you want to learn about ways to make your builds faster, read Optimize Your ... Gradle and the Android plugin allow you...
Read more >
How to set project.version by passing version property on ...
Set the property only in the gradle.properties file (i.e. remove it from build.gradle ). Also make sure the options come before the command...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found