[Development tool] gradle User Manual: Build a task

Source: Internet
Author: User

General task

When a plugin is applied to build file, a series of build tasks are automatically created to run. This is also true for Java Plugin and Android plugin.

We have the following four Conventions for tasks:

  • Assemble tasks to collect output from all projects

  • Check task, run all verification

  • Build tasks, both collection and verification

  • Clean task, clear all project output

Assemble, check and build tasks do not do anything themselves. They are just plug-in anchors. The real tasks are added and executed by plug-in.

The advantage of this is that you can call the same command to execute whatever project you are in.

Through the command line, you can get more advanced tasks. The command is as follows:

[Java]View plaincopy
  1. Gradle tasks

List all currently running tasks and view their dependencies:

[Java]View plaincopy
  1. Gradle tasks -- all

Note: gradle automatically detects the input and output stated in a task. When two build tasks are repeated, gradle reports that all tasks are in the up-to-date status.

Java Project Task

Java Plugin creates two tasks, respectively mounted to the anchor task, as follows:

[Java]View plaincopy
  1. Assemble
  2. Jar this task creates the output.
  3. Check
  4. Test this task runs the tests.
  • The jar task is to compile and execute the Java source code.
  • The test task is to run the unit test

Generally, only assemble and check are used for tasks in Java projects. For more tasks, see here.

Android task

Android tasks include "connectedcheck" and "devicecheck" more than general tasks. This allows the project to ignore whether the device is connected and perform the check task normally.

  • Assemble tasks to collect output from all projects

  • Check task, run all verification

  • Connectedcheck task, run all the verification tasks that need to be linked to a device or simulator, and run them in parallel

  • The devicecheck task is used to run the verification of the remote device called for CI servers.

  • Build tasks, both collection and verification

  • Clean task, clear all project output

Note: The build task does not depend on devicecheck or connectedcheck.

An android project has at least two outputs: Debug APK and release APK. both outputs have their own corresponding anchor tasks to implement their respective build. When the Assemble task is called, assembledebug and assumerelease are called at the same time to ensure that there are two outputs.

[Java]View plaincopy
  1. Assemble
  2. -Assembledebug
  3. -Release release

Tip: gradle supports the abbreviated camel naming method. For example, when you run a command, you can use AR instead of assumerelease:

 

[Java]View plaincopy
  1. Gradle AR = gradle assumerelease

Check tasks also have their own dependencies:

  • Check

--- LINT (not implemented yet, Khan)

  • Connectedcheck

--- Connectedinstrumenttest
--- Connecteduiautomatortest (this is not implemented yet ......)

  • Devicecheck

Depends on the extension points of other plug-ins for testing when the task is created.

Finally, to be able to install and uninstall, Android plugin creates the install/uninstall task for all build types (debug, release, test), but requires signing.

[Development tool] gradle User Manual: Build a task

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.