[Transfer]-gradle User Guide (iii): Build Tasks

Source: Internet
Author: User

Original address: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Using-sourceCompatibility-1.7

Translation: Android Studio Chinese Group (sledgehammer translation)

Continuation: Gradle (i) | Gradle (b)

Common tasks

When a plugin is applied to the build file, a series of build tasks are automatically created to run. Both Java plugin and Android plugin will do the same.

We have the following four contracts for tasks:

    • Assemble task, assemble all project outputs
    • Check task, run all checksums
    • Build task, both pooled and verified
    • Clean task, clear all project outputs

Assemble, check and build tasks themselves do nothing, they are just plugin anchor points, the real task is to add execution by plugin.

The advantage of this is that you can invoke the same command to execute no matter what project you are in.

From the command line, you can get a higher level of task with the following command:

Gradle Tasks

List all tasks that are currently running, and view dependencies between them:

Gradle Tasks--all

Note: Gradle automatically detects the input and output declared in a task. When you repeat the build task two times, Gradle reports that all current tasks are up-to-date state.

Tasks for Java Projects

Java plugin creates two tasks, each of which is linked to an anchor task, as follows:

Assemble
The jar this task creates the output.
Check
Test this task runs the tests.

    • The jar task is to compile and execute Java source code.
    • The test task is to run the unit test

Typically, the tasks in a Java project will only use two of the assemble and check, and more of the other task details here.

Android Task

Android's task is more "Connectedcheck" and "Devicecheck" than the four most common tasks, which is to let the project ignore whether the device is connected and perform the check task normally.

    • Assemble task, assemble all project outputs
    • Check task, run all checksums
    • Connectedcheck tasks, run all checks that require a linked device or simulator, run in parallel
    • Devicecheck task, run call remote device check, apply to CI Servers
    • Build task, both pooled and verified
    • Clean task, clear all project outputs

Note: The build task is not dependent on Devicecheck or Connectedcheck

An Android project has at least two outputs, one is the debug apk, and the other is the release APK. Both outputs have their own corresponding anchor task to implement their respective build calls to the assemble task when both Assembledebug and assemblerelease are called to ensure that there are two outputs.

Assemble
-Assembledebug
-Assemblrelease

Tip:gradle supports the shorthand for camel naming, such as when the command line is lost, AR can be used instead of assemblerelease, if no other task is ar shorthand:

Gradle AR = Gradle assemblerelease

Check tasks also have their own dependencies:

    • Check

---lint (not yet realized, Khan one)

    • Connectedcheck

---connectedinstrumenttest
---connecteduiautomatortest (this has not yet been realized ...)

    • Devicecheck

Depending on the extension point that the other plug-in implements testing when the task is created

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

[Transfer]-gradle User Guide (iii): Build Tasks

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.