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

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

命令 ;

以上是关于Android Gradle 插件自定义 Gradle 任务 ② ( 在 Terminal 面板中执行 gradlew task 命令显示所有任务 | 命令行输出所有任务 | 单独执行指定任务 )的主要内容,如果未能解决你的问题,请参考以下文章

Android之Gradle的理解

Android Gradle 插件Gradle 自定义 Plugin 插件 ⑤ ( 自定义插件中获定义方法 | 在插件中创建 Gradle 任务 | 代码示例 )

Android Gradle 插件Gradle 自定义 Plugin 插件 ⑦ ( 自定义 Gradle 插件导入方式 | buildSrc 插件导入 | 构建脚本中自定义插件 | 独立文件 )

Android Gradle 插件Gradle 自定义 Plugin 插件 ⑦ ( 自定义 Gradle 插件导入方式 | buildSrc 插件导入 | 构建脚本中自定义插件 | 独立文件 )

Android Gradle 插件自定义 Gradle 插件模块 ② ( 在模块中定义插件 | 引入自定义 Gradle 插件模块 | 配置 Gradle 插件上传选项 | 配置分组名称版本号 )

Android Gradle 插件Gradle 自定义 Plugin 插件 ④ ( 为自定义 Gradle 插件的扩展配置扩展 | 在自定义插件中获取扩展属性 )