Android Gradle 插件LintOptions 配置 ① ( BaseExtension#lintOptions 配置 | LintOptions 配置简介 | lint 工具 )
Posted 韩曙亮
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Gradle 插件LintOptions 配置 ① ( BaseExtension#lintOptions 配置 | LintOptions 配置简介 | lint 工具 )相关的知识,希望对你有一定的参考价值。
文章目录
Android Plugin DSL Reference 参考文档 :
-
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
-
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
-
NDK 参考文档 : Add C and C++ Code to Your Project.
一、BaseExtension#lintOptions 配置
BaseExtension 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.BaseExtension.html
LintOptions ( build.gradle#android#lintOptions ) 文档位置 : android-gradle-dsl/2.3/com.android.build.gradle.internal.dsl.LintOptions.html
1、BaseExtension#lintOptions 脚配块配置简介
BaseExtension#lintOptions 脚配块配置 用于配置 lint 选项 ;
该脚本块主要是设置 BaseExtension 中的 LintOptions lintOptions 属性 ;
2、BaseExtension#lintOptions 脚配块配置原型
BaseExtension#lintOptions 脚配块配置原型 :
lintOptions
Configures lint options.
Delegates to:
LintOptions from lintOptions
packagingOptions
3、BaseExtension#lintOptions 属性配置原型
BaseExtension#lintOptions 属性配置原型 : BaseExtension#lintOptions 属性是 LintOptions 类型的 ;
LintOptions lintOptions
Lint options.
二、LintOptions 配置简介
LintOptions 配置是用于 配置 lint 工具的 ;
lint 工具的作用是帮助开发者 优化代码结构质量 , 如检查未使用的变量等 , 发现的问题可能不影响使用 , 但是可以优化代码结构 ;
lint 工具在 SDK 中的 tools\\bin 目录中 ;
执行
lint --help
命令 , 可以打印出 lint 工具的帮助文档 , 完整命令行输出如下 :
D:\\001_Develop\\001_SDK\\Sdk\\tools\\bin>lint --help
Usage: lint [flags] <project directories>
Flags:
--help This message.
--help <topic> Help on the given topic, such as "suppress".
--list List the available issue id's and exit.
--version Output version information and exit.
--exitcode Set the exit code to 1 if errors are found.
--show List available issues along with full
explanations.
--show <ids> Show full explanations for the given list of
issue id's.
Enabled Checks:
--disable <list> Disable the list of categories or specific
issue id's. The list should be a
comma-separated list of issue id's or
categories.
--enable <list> Enable the specific list of issues. This
checks all the default issues plus the
specifically enabled issues. The list should
be a comma-separated list of issue id's or
categories.
--check <list> Only check the specific list of issues. This
will disable everything and re-enable the
given list of issues. The list should be a
comma-separated list of issue id's or
categories.
-w, --nowarn Only check for errors (ignore warnings)
-Wall Check all warnings, including those off by
default
-Werror Treat all warnings as errors
--config <filename> Use the given configuration file to determine
whether issues are enabled or disabled. If a
project contains a lint.xml file, then this
config file will be used as a fallback.
--baseline Use (or create) the given baseline file to
filter out known issues.
Output Options:
--quiet Don't show progress.
--fullpath Use full paths in the error output.
--showall Do not truncate long messages, lists of
alternate locations, etc.
--nolines Do not include the source file lines with
errors in the output. By default, the error
output includes snippets of source code on
the line containing the error, but this flag
turns it off.
--html <filename> Create an HTML report instead. If the
filename is a directory (or a new filename
without an extension), lint will create a
separate report for each scanned project.
--url filepath=url Add links to HTML report, replacing local
path prefixes with url prefix. The mapping
can be a comma-separated list of path
prefixes to corresponding URL prefixes, such
as
C:\\temp\\Proj1=http://buildserver/sources/temp
/Proj1. To turn off linking to files, use
--url none
--simplehtml <filename> Create a simple HTML report
--xml <filename> Create an XML report instead.
Project Options:
--project <file> Use the given project layout descriptor file
to describe the set of available sources,
resources and libraries. Used to drive lint
with build systems not natively integrated
with lint.
--resources <dir> Add the given folder (or path) as a resource
directory for the project. Only valid when
running lint on a single project.
--sources <dir> Add the given folder (or path) as a source
directory for the project. Only valid when
running lint on a single project.
--classpath <dir> Add the given folder (or jar file, or path)
as a class directory for the project. Only
valid when running lint on a single project.
--libraries <dir> Add the given folder (or jar file, or path)
as a class library for the project. Only
valid when running lint on a single project.
--compile-sdk-version <version> Use the given compileSdkVersion to pick an
SDK target to resolve android API call to
--sdk-home <dir> Use the given SDK instead of attempting to
find it relative to the lint installation or
via $ANDROID_HOME
Exit Status:
0 Success.
1 Lint errors detected.
2 Lint usage.
3 Cannot clobber existing file.
4 Lint help.
5 Invalid command-line argument.
D:\\001_Develop\\001_SDK\\Sdk\\tools\\bin>
以上是关于Android Gradle 插件LintOptions 配置 ① ( BaseExtension#lintOptions 配置 | LintOptions 配置简介 | lint 工具 )的主要内容,如果未能解决你的问题,请参考以下文章
Android Gradle 插件Gradle 自定义 Plugin 插件 ③ ( 自定义插件作用 | Android Gradle 插件的扩展 | 自定义 Extension 扩展 )
Android Gradle 插件Gradle 自定义 Plugin 插件 ⑥ ( 在 buildSrc 模块中依赖 Android Gradle 插件 | 完整代码示例 )
Android Gradle 插件Gradle 自定义 Plugin 插件 ⑥ ( 在 buildSrc 模块中依赖 Android Gradle 插件 | 完整代码示例 )
Android Gradle 插件Gradle 自定义 Plugin 插件 ② ( buildSrc 目录中实现 Gradle 插件 | 实现 Gradle 插件代码 | 模块引入插件并编译 )
Android Gradle 插件Android Module 模块 build.gradle 构建脚本 Groovy 语法分析 ① ( Gradle 二进制插件引入 | Gradle依赖配置 )
Android Gradle 插件Android Module 模块 build.gradle 构建脚本 Groovy 语法分析 ① ( Gradle 二进制插件引入 | Gradle依赖配置 )