【Android Gradle 插件】LintOptions 配置 ① ( BaseExtension#lintOptions 配置 | LintOptions 配置简介 | lint 工具 )

Android Plugin DSL Reference 参考文档 :





一、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>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/han1202012/article/details/124716100
今日推荐