使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
lint
lint 检查以验证 Gradle API 的使用情况
最近更新时间 |
稳定版 |
候选版 |
Beta 版 |
Alpha 版 |
2025 年 5 月 20 日 |
- |
- |
- |
1.0.0-alpha05 |
声明依赖项
如需添加 Lint 的依赖项,您必须将 Google Maven 制品库添加到项目中。如需了解详情,请参阅 Google 的 Maven 代码库。
在应用或模块的 build.gradle
文件中添加所需工件的依赖项:
Groovy
plugins {
id("com.android.lint")
}
dependencies {
lintChecks "androidx.lint:lint-gradle:1.0.0-alpha05"
}
Kotlin
plugins {
id("com.android.lint")
}
dependencies {
lintChecks("androidx.lint:lint-gradle:1.0.0-alpha05")
}
如需详细了解依赖项,请参阅添加 build 依赖项。
反馈
您的反馈将帮助我们改进 Jetpack。如果您发现了新问题,或对此库有任何改进建议,请告诉我们。创建新问题前,请先查看此库中的现有问题。您可以点击星标按钮,为现有问题投票。
创建新问题
如需了解详情,请参阅问题跟踪器文档。
此工件没有版本说明。
版本 1.0
版本 1.0.0-alpha05
2025 年 5 月 20 日
发布了 androidx.lint:lint-gradle:1.0.0-alpha05
。版本 1.0.0-alpha05 包含这些提交内容。
新功能
- 添加了检查,以便针对
configurations.create
和 configurations.maybeCreate
的用法发出警告,因为从 Gradle 8.14 开始,这两者会导致该配置提前实现,因此应替换为 configurations.register
。
- 添加了检查,以捕获内部 Kotlin Gradle 插件 API 的用法
- 添加了检查,以捕获
evaluationDependsOn
和 evaluationDependsOnChildren
的用法,因为在使用隔离项目功能时,这并不安全。
版本 1.0.0-alpha04
2025 年 4 月 23 日
发布了 androidx.lint:lint-gradle:1.0.0-alpha04
。版本 1.0.0-alpha04 包含这些提交内容。
新功能
- 添加了对意外
Provider<String>.toString
调用的检查,因为它们可能是 bug。
- 添加了检查,以捕获来自内部类型的方法、属性和字段的使用情况。
bug 修复
- 修复了
GradleProjectIsolation
检查,以允许使用 Project.isolated
。
- 修复了
WithTypeWithoutConfigureEach
检查,以捕获未使用 configureEach
的 Project.tasks.withType<Task>()
用法。
- 修复了
InternalGradleApiUsage
检查,以捕获内部 API 的完全限定用法。
版本 1.0.0-alpha03
2024 年 12 月 11 日
发布了 androidx.lint:lint-gradle:1.0.0-alpha03
。版本 1.0.0-alpha03 包含这些提交内容。
新功能
- 捕获对
Provider<>.toString
的调用,因为这样做几乎总会导致 bug。
- 捕获对
TaskContainer
的 Kotlin 集合扩展函数的调用,因为这些调用会导致提前创建 Task
。
- 捕获传入
Configuration
的 ConfigurableFileCollection.from
调用,因为这会导致提示使用 project.files(configuration)
或 configuration.incoming.artifactView {}.files
的配置提前解析。
- 捕获
Property<File>
的用法,建议使用 RegularFileProperty
或 DirectoryProperty
,因为它会强制使用目录而非文件。
版本 1.0.0-alpha02
2024 年 9 月 4 日
发布了 androidx.lint:lint-gradle:1.0.0-alpha02
。版本 1.0.0-alpha02 包含这些提交内容。
新功能
- 添加了针对不建议使用的
GradleRunner.withPluginClasspath
API 的检查。
- 通过标记对
TaskContainer.withType
的调用(而未调用 configureEach
),针对对延迟配置有问题的 API 添加了检查。
- 通过标记对
Project.getRootProject
、Project.findProject
、Project.getParent
、Project.findProperty
、Project.getProperties
、Project.hasProperty
、Project.property
的调用,添加了对 Gradle 项目隔离有问题的 API 的检查。
版本 1.0.0-alpha01
2024 年 2 月 21 日
发布了 androidx.lint:lint-gradle:1.0.0-alpha01
。版本 1.0.0-alpha01 中包含这些提交内容。
新功能
- 一组初始 lint 检查,供 Gradle 插件作者使用,以帮助他们发现代码中的错误。它们应用于应用
java-gradle-plugin
的 Gradle 项目。它会捕获内部 Gradle 和 Android Gradle 插件 API 的使用情况以及提前任务配置。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# lint\n====\n\nAPI Reference \n[androidx.lint](/reference/kotlin/androidx/lint/package-summary) \nLint checks to verify usage of Gradle APIs \n\n| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |\n|---------------|----------------|-------------------|--------------|----------------------------------------------------------------|\n| May 20, 2025 | - | - | - | [1.0.0-alpha05](/jetpack/androidx/releases/lint#1.0.0-alpha05) |\n\nDeclaring dependencies\n----------------------\n\nTo add a dependency on Lint, you must add the Google Maven repository to your\nproject. Read [Google's Maven repository](/studio/build/dependencies#google-maven)\nfor more information.\n\nAdd the dependencies for the artifacts you need in the `build.gradle` file for\nyour app or module: \n\n### Groovy\n\n```groovy\nplugins {\n id(\"com.android.lint\")\n}\ndependencies {\n lintChecks \"androidx.lint:lint-gradle:1.0.0-alpha05\"\n}\n```\n\n### Kotlin\n\n```kotlin\nplugins {\n id(\"com.android.lint\")\n}\ndependencies {\n lintChecks(\"androidx.lint:lint-gradle:1.0.0-alpha05\")\n}\n```\n\nFor more information about dependencies, see [Add build dependencies](/studio/build/dependencies).\n\nFeedback\n--------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues or have\nideas for improving this library. Please take a look at the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:1518777%20status:open)\nin this library before you create a new one. You can add your vote to an existing issue by\nclicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=1518777&template=1946997)\n\nSee the [Issue Tracker documentation](https://developers.google.com/issue-tracker)\nfor more information.\n\nThere are no release notes for this artifact.\n\nVersion 1.0\n-----------\n\n### Version 1.0.0-alpha05\n\nMay 20, 2025\n\n`androidx.lint:lint-gradle:1.0.0-alpha05` is released. Version 1.0.0-alpha05 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/7bbd2bffb18b5a7d6ab44019d31979acc72315a7..cd41781824511ce4d5c4a05d2df4aaaee669f0bc/lint/lint-gradle).\n\n**New Features**\n\n- Add a check to warn about usages of `configurations.create` and `configurations.maybeCreate` as these cause eager realization of that configuration starting with Gradle 8.14 and thus should be replaced with `configurations.register`.\n- Add a check to catch usages of internal Kotlin Gradle Plugin APIs\n- Add a check to catch usages of `evaluationDependsOn` and `evaluationDependsOnChildren` as it is not safe with Isolated Projects feature.\n\n### Version 1.0.0-alpha04\n\nApril 23, 2025\n\n`androidx.lint:lint-gradle:1.0.0-alpha04` is released. Version 1.0.0-alpha04 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/2ffcbb08c7221e79b12c0ef234bcfb5517d10ece..7bbd2bffb18b5a7d6ab44019d31979acc72315a7/lint/lint-gradle).\n\n**New Features**\n\n- Add a check for accidental `Provider\u003cString\u003e.toString` calls as they are likely bugs.\n- Add check to catch uses of methods, properties, fields coming from internal types.\n\n**Bug Fixes**\n\n- Fix `GradleProjectIsolation` check to allow usage of `Project.isolated`.\n- Fix `WithTypeWithoutConfigureEach` check to catch uses of `Project.tasks.withType\u003cTask\u003e()` without `configureEach`.\n- Fix `InternalGradleApiUsage` check to catch fully qualified usages of internal APIs.\n\n### Version 1.0.0-alpha03\n\nDecember 11, 2024\n\n`androidx.lint:lint-gradle:1.0.0-alpha03` is released. Version 1.0.0-alpha03 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/9cd42c5cbf5e69b0223d5b0c357593175182f365..2ffcbb08c7221e79b12c0ef234bcfb5517d10ece/lint/lint-gradle).\n\n**New Features**\n\n- Catch calls to `Provider\u003c\u003e.toString` as it is nearly always a bug to do that.\n- Catch calls of Kotlin collection extension functions on `TaskContainer` as these cause eager `Task` creation.\n- Catch calls to `ConfigurableFileCollection.from` passing in a `Configuration` as that causes eager resolution of the configuration suggesting to use `project.files(configuration)` or `configuration.incoming.artifactView {}.files`.\n- Catch usages of `Property\u003cFile\u003e` suggesting to use `RegularFileProperty` or `DirectoryProperty` as it is enforcing the use directory vs file.\n\n### Version 1.0.0-alpha02\n\nSeptember 4, 2024\n\n`androidx.lint:lint-gradle:1.0.0-alpha02` is released. Version 1.0.0-alpha02 contains [these commits](https://android.googlesource.com/platform/frameworks/support/+log/e1b82c49c59d8e976ce558aba5586f6c61bc9054..9cd42c5cbf5e69b0223d5b0c357593175182f365/lint/lint-gradle).\n\n**New Features**\n\n- Added a check for discouraged `GradleRunner.withPluginClasspath` API.\n- Added checks for APIs that are problematic for lazy configuration by flagging calls to `TaskContainer.withType` without calling `configureEach`.\n - Added checks for APIs that are problematic for Gradle Project Isotation by flagging calls to `Project.getRootProject`, `Project.findProject`, `Project.getParent`, `Project.findProperty`, `Project.getProperties`, `Project.hasProperty`, `Project.property`.\n\n### Version 1.0.0-alpha01\n\nFebruary 21, 2024\n\n`androidx.lint:lint-gradle:1.0.0-alpha01` is released. [Version 1.0.0-alpha01 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/e1b82c49c59d8e976ce558aba5586f6c61bc9054/lint/lint-gradle)\n\n**New Features**\n\n- An initial set of lint checks for Gradle Plugin authors to help them catch mistakes in their code. They are expected to be used on Gradle projects that apply `java-gradle-plugin`. It will catch uses of internal Gradle and Android Gradle Plugin APIs and eager task configuration."]]