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
- Gradle tasks
List all currently running tasks and view their dependencies:
[Java]View plaincopy
- 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
- Assemble
- Jar this task creates the output.
- Check
- 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
- Assemble
- -Assembledebug
- -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
- Gradle AR = gradle assumerelease
Check tasks also have their own dependencies:
--- LINT (not implemented yet, Khan)
--- Connectedinstrumenttest
--- Connecteduiautomatortest (this is not implemented yet ......)
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