【Android Gradle 插件】自定义 Gradle 任务 ② ( 在 Terminal 面板中执行 gradlew task 命令显示所有任务 | 命令行输出所有任务 | 单独执行指定任务 )

Android Plugin DSL Reference 参考文档 :





一、在 Terminal 面板中执行 gradlew task 命令显示所有任务



在 Terminal 面板中执行 gradlew task 命令显示所有任务 : 在每个任务之后都有该任务的具体作用 ;

D:\002_Project\002_Android_Learn\Android_UI>gradlew task

> Configure project :app
'Hello World!'
'Hello World!2'
'Hello World!'
'Hello World!2'
WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
This repository is deprecated and it will be shut down in the future.
See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
Currently detected usages in: root project 'Android_UI', project ':app'

> Task :tasks

------------------------------------------------------------
Tasks runnable from root project
------------------------------------------------------------

Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for the base and test modules
sourceSets - Prints out all the source sets defined in this project.

Build tasks
-----------
assemble - Assemble main outputs for all the variants.
assembleAndroidTest - Assembles all the Test applications.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
bundle - Assemble bundles for all the variants.
clean - Deletes the build directory.
cleanBuildCache - Deletes the build cache directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Cleanup tasks
-------------
lintFix - Runs lint on all variants and applies any safe suggestions to the source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'Android_UI'.
components - Displays the components produced by root project 'Android_UI'. [incubating]
dependencies - Displays all dependencies declared in root project 'Android_UI'.
dependencyInsight - Displays the insight into a specific dependency in root project 'Android_UI'.
dependentComponents - Displays the dependent components of components in root project 'Android_UI'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'Android_UI'. [incubating]
outgoingVariants - Displays the outgoing variants of root project 'Android_UI'.
projects - Displays the sub-projects of root project 'Android_UI'.
properties - Displays the properties of root project 'Android_UI'.
tasks - Displays the tasks runnable from root project 'Android_UI' (some of the displayed tasks may belong to subprojects).

Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.

Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
lintVitalRelease - Runs lint on just the fatal issues in the release build.
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testReleaseUnitTest - Run unit tests for the release build.

To see all tasks and more detail, run gradlew tasks --all

To see more detail about a task, run gradlew help --task <task>

BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
D:\002_Project\002_Android_Learn\Android_UI>

在这里插入图片描述





二、执行 gradlew task --all 命令在命令行输出所有任务



执行

gradlew task --all

命令 , 可以输出所有任务 , 主要是在 执行 gradlew task 命令的基础上 , 将 other 分组下的任务显示出来 ;

在这里插入图片描述





三、单独执行指定的任务



这里以执行 app 下的 assemble 任务为例 :

想要单独执行指定的 Task 任务 , 可以右键点击 Gradle 面板 中任务列表中的任务项 , 然后选择第一个选项执行该任务 ;

在这里插入图片描述

也可以在 Terminal 面板 中 , 执行

gradle :app:assemble

命令 ;

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/han1202012/article/details/126938573