Gradle Running a Build - Gradle

What is Gradle Running a Build?

Gradle presents a command line to execute build script. it may execute multiple project at a time. This chapter explains the way to execute more than one tasks using unique options.

Executing Multiple tasks

You may execute multiple responsibilities from a single build file. Gradle can deal with that construct file using gradle command. This command will bring together every project in the order that they may be listed and execute every project in conjunction with the dependencies the usage of unique options.

Example − There are four tasks - task1, task2, task3, and task4. Task3 and task4 relies upon on project 1and task2. take a look at the following diagram.

Gradle Running a Build


Within the above four tasks are dependent on every other, represented with an arrow image. test the following code. copy and paste it into build.gradle file.

You can use the following code for compiling and executing the above task.

If the command is executed successfully, you will get the following output.

Excluding Tasks

While with the exception of a project from the execution you may use –x option along with the gradle command and mention the name of the project, that you need to exclude.

Use the following command to exclude task4 from the above script.

If the command is executed successfully, you will get the following output.

Continuing the Build When a Failure Occurs

Gradle will abort the execution and fail the build as quickly as any project fails. you can continue the execution even when a failure takes place. For this, you need to use –continue choice with the gradle command. It handles every project separately along with their dependencies. The important point is, it will catch each encountered failure and report on the stop of the execution of the build. suppose if a project fails, then the based next tasks also will no longer be done.

Selecting Which Build to Execute

When you run the gradle command, it looks for a build file within the present day directory. you can use the –b choice to choose a selected build file along with the absolute course. the following example indicates choosing a project ‘hello’ from myproject.gradle file, that is located in the subdir/.

You can use the following command to execute the above script.

If the command is executed successfully, you will get the following output.

Obtaining Build Information

Gradle presents numerous built-in tasks for retrieving the built-information details the project and the task. this may be beneficial to recognize the structure and the dependencies of your build and for debugging issues. you can use project file plugin to add tasks on your venture, if you want to generate these reports.

Listing projects

you can list the project hierarchy of the chosen project and their sub tasks integrated gradle –q projects command. here is the example, use integrated command to list all of the project integrated build file.

Output −


The report shows the description of each project, if specified. You can use the following command to specify the description. Paste it in the build.gradle file.


Listing Tasks

you can list all the tasks which belong to the multiple projects through using the following command.


If the command is executed successfully, you will get the following output.

You can use the following command to display the information of all tasks.


If the command is executed successfully, you will get the following output.

Following is a list of commands with their descriptions.

Sr. No.

Command

Description

1

gradle –q help –task <task name>

Provides the usage information (such as path, type, description, group) about a specific task or multiple tasks.

2

gradle –q dependencies

Provides a list of dependencies of the selected project.

3

gradle -q api:dependencies --configuration <task name>

Provides the list of limited dependencies respective to configuration.

4

gradle –q buildEnvironment

Provides the list of build script dependencies.

5

gradle –q dependencyInsight

Provides an insight into a particular dependency.

6

Gradle –q properties

Provides the list of properties of the selected project.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Gradle Topics