前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Android Gradle 插件】LintOptions 配置 ① ( BaseExtension#lintOptions 配置 | LintOptions 配置简介 | lint 工具 )

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

作者头像
韩曙亮
发布2023-03-30 15:24:42
8020
发布2023-03-30 15:24:42
举报
文章被收录于专栏:韩曙亮的移动开发专栏

文章目录

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 { } 脚配块配置原型 :

代码语言:javascript
复制
lintOptions { }
Configures lint options.

Delegates to:
LintOptions from lintOptions
packagingOptions { }

3、BaseExtension#lintOptions 属性配置原型

BaseExtension#lintOptions 属性配置原型 : BaseExtension#lintOptions 属性是 LintOptions 类型的 ;

代码语言:javascript
复制
LintOptions lintOptions
Lint options.

二、LintOptions 配置简介


LintOptions 配置是用于 配置 lint 工具的 ;

lint 工具的作用是帮助开发者 优化代码结构质量 , 如检查未使用的变量等 , 发现的问题可能不影响使用 , 但是可以优化代码结构 ;

lint 工具在 SDK 中的 tools\bin 目录中 ;

在这里插入图片描述
在这里插入图片描述

执行

代码语言:javascript
复制
lint --help

命令 , 可以打印出 lint 工具的帮助文档 , 完整命令行输出如下 :

代码语言:javascript
复制
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>
在这里插入图片描述
在这里插入图片描述
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-05-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 一、BaseExtension#lintOptions 配置
    • 1、BaseExtension#lintOptions { } 脚配块配置简介
      • 2、BaseExtension#lintOptions { } 脚配块配置原型
        • 3、BaseExtension#lintOptions 属性配置原型
        • 二、LintOptions 配置简介
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档