Android Gradle 插件自定义 Gradle 任务 ② ( 在 Terminal 面板中执行 gradlew task 命令显示所有任务 | 命令行输出所有任务 | 单独执行指定任务 )
Posted 韩曙亮
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Gradle 插件自定义 Gradle 任务 ② ( 在 Terminal 面板中执行 gradlew task 命令显示所有任务 | 命令行输出所有任务 | 单独执行指定任务 )相关的知识,希望对你有一定的参考价值。
文章目录
Android Plugin DSL Reference 参考文档 :
-
Android Studio 构建配置官方文档 : https://developer.android.google.cn/studio/build
-
添加构建依赖项 参考文档 : https://developer.android.google.cn/studio/build/dependencies
-
Android Gradle 插件配置与 Gradle 配置关联 : 【Android Gradle 插件】Gradle 依赖管理 ① ( org.gradle.api.Project 配置 | Android Gradle 插件配置与 Gradle 配置关联 ) ★
-
Android Gradle 插件文档主页 : https://google.github.io/android-gradle-dsl/2.3/
-
BaseExtension 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.BaseExtension.html
-
AppExtension ( build.gradle#android 配置 ) 文档位置 : android-gradle-dsl-gh-pages/2.3/com.android.build.gradle.AppExtension.html
-
build.gradle#android 模块配置文档 : android-gradle-dsl/2.3/com.android.build.gradle.AppExtension.html
-
ProductFlavor ( build.gradle#android#defaultConfig 配置 ) 文档 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.ProductFlavor.html
-
ProductFlavor#externalNativeBuild 配置 ( build.gradle#android#defaultConfig#externalNativeBuild 配置 ) : com.android.build.gradle.internal.dsl.ProductFlavor:externalNativeBuild
-
ExternalNativeBuildOptions ( build.gradle#android#defaultConfig#externalNativeBuild 配置 ) 文档位置 : android-gradle-dsl-gh-pages/2.3/com.android.build.gradle.internal.dsl.ExternalNativeBuildOptions.html
-
NdkBuildOptions ( build.gradle#android#defaultConfig#externalNativeBuild#ndkBuild 配置 ) 文档位置 : android-gradle-dsl-gh-pages/2.3/com.android.build.gradle.internal.dsl.NdkBuildOptions.html
-
CmakeOptions ( build.gradle#android#defaultConfig#externalNativeBuild#cmake 配置 ) 文档位置 : android-gradle-dsl-gh-pages/2.3/com.android.build.gradle.internal.dsl.CmakeOptions.html
-
JackOptions ( build.gradle#android#defaultConfig#jackOptions 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.JackOptions.html
-
AnnotationProcessorOptions ( 注解处理器配置 ) ( build.gradle#android#defaultConfig#javaCompileOptions配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.AnnotationProcessorOptions.html
-
NdkOptions ( build.gradle#android#defaultConfig#ndk 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.NdkOptions.html
-
NDK 参考文档 : Add C and C++ Code to Your Project.
-
VectorDrawablesOptions ( build.gradle#android#defaultConfig#vectorDrawables 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.VectorDrawablesOptions.html
-
BuildType ( build.gradle#android#buildTypes 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.BuildType.html
-
SigningConfig ( build.gradle#android#signingConfigs 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.SigningConfig.html
-
AaptOptions ( build.gradle#android#aaptOptions 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.AaptOptions.html
-
AndroidSourceSets ( build.gradle#android#sourceSets 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.api.AndroidSourceSet.html
-
AndroidSourceDirectorySet ( build.gradle#android#sourceSets#aidl/assets/java/jni/jniLibs 配置 ) 文档位置 :android-gradle-dsl/2.3/com.android.build.gradle.api.AndroidSourceDirectorySet.html
-
AndroidSourceFile ( build.gradle#android#sourceSets#manifest 配置 ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.api.AndroidSourceFile.html
-
DataBindingOptions ( build.gradle#android#dataBinding ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.DataBindingOptions.html
-
DexOptions ( build.gradle#android#dexOptions ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.DexOptions.html
-
LintOptions ( build.gradle#android#lintOptions ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.LintOptions.html
-
PackagingOptions ( build.gradle#android#packagingOptions ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.PackagingOptions.html
-
Splits ( build.gradle#android#splits ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.Splits.html
-
AbiSplitOptions ( build.gradle#android#splits#abi ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.AbiSplitOptions.html
-
LanguageSplitOptions ( build.gradle#android#splits#language ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.LanguageSplitOptions.html
-
DensitySplitOptions ( build.gradle#android#splits#density ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.DensitySplitOptions.html
-
TestOptions ( build.gradle#android#testOptions ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.TestOptions.html
-
Android 测试相关文档 : https://developer.android.google.cn/training/testing
-
UnitTestOptions ( build.gradle#android#testOptions#unitTests ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.TestOptions.UnitTestOptions.html
-
org.gradle.api.tasks.testing.Test 单元测试配置类 : https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html
-
LibraryExtension ( Library 依赖库的 build.gradle#android 配置 ) 文档 : android-gradle-dsl/2.3/com.android.build.gradle.LibraryExtension.html
-
org.gradle.api.Project 配置 ( build.gradle 根配置 ) 文档 : https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html
-
org.gradle.api.artifacts.dsl.DependencyHandler 配置 ( build.gradle#dependencies#implementation 配置 ) : https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/dsl/DependencyHandler.html
-
添加构建依赖项 参考文档 : https://developer.android.google.cn/studio/build/dependencies
一、在 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 插件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 插件的扩展配置扩展 | 在自定义插件中获取扩展属性 )