To run a Gradle task from the command line, you can use the following command:
gradle <taskName>
Example:
To run the build
task, you would use the following command:
gradle build
Additional Tips:
-
Specify the Gradle project directory: If you are not in the root directory of your Gradle project, you need to specify the path to the project directory. For example:
gradle -p /path/to/project build
-
Run a specific task from a specific subproject: To run a task from a specific subproject, use the following syntax:
gradle :<subprojectName>:<taskName>
Example:
gradle :app:build
-
List available tasks: To see a list of available tasks, use the following command:
gradle tasks
-
Get help for a specific task: To get help on a specific task, use the following command:
gradle help <taskName>
-
Run a task with specific options: You can pass options to a task using the following syntax:
gradle <taskName> --option1=value1 --option2=value2
Example:
gradle build --info
Remember: The exact commands and options may vary depending on your Gradle project configuration.