Allow gradle options to be passed to build
See original GitHub issueDescribe 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:
- Created 3 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There’s ongoing effort to add custom gradle options with #1729
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.