透過集合功能整理內容
你可以依據偏好儲存及分類內容。
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")
}
如要進一步瞭解依附元件,請參閱「新增建構依附元件」一文。
意見回饋
您的意見可協助我們改善 Jetpack。如果您發現新問題,或是有改進這個程式庫的建議,請告訴我們。回報新問題前,請先查看這個程式庫的現有問題。只要按一下星號按鈕,即可投票給現有的問題。
建立新問題
詳情請參閱 Issue Tracker 文件。
這個構件沒有任何版本資訊。
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
的用法,因為在 Isolated Projects 功能中使用這些項目並不安全。
1.0.0-alpha04 版本
2025 年 4 月 23 日
發布 androidx.lint:lint-gradle:1.0.0-alpha04
。1.0.0-alpha04 版包含這些修訂版本。
新功能
- 新增檢查程序,以防意外的
Provider<String>.toString
呼叫,因為這可能是錯誤。
- 新增檢查項目,以便擷取來自內部類型的使用方法、屬性和欄位。
修正錯誤
- 修正
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
的呼叫,因為這幾乎總是會發生錯誤。
- 在
TaskContainer
上擷取 Kotlin 集合擴充功能函式的呼叫,因為這些會導致急迫的 Task
建立。
- 擷取對
ConfigurableFileCollection.from
的呼叫,並在 Configuration
中傳遞,因為這會導致系統急切解析建議使用 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 進行檢查的功能。
- 新增檢查項目,針對不呼叫
configureEach
而呼叫 TaskContainer.withType
的 API 進行檢查。
- 針對 Gradle 專案隔離作業中出現問題的 API 新增檢查項目,標示對
Project.getRootProject
、Project.findProject
、Project.getParent
、Project.findProperty
、Project.getProperties
、Project.hasProperty
、Project.property
的呼叫。
1.0.0-alpha01 版
2024 年 2 月 21 日
發布 androidx.lint:lint-gradle:1.0.0-alpha01
。1.0.0-alpha01 版包含此連結所列的修訂項目。
新功能
- 針對 Gradle 外掛程式作者提供初始的 Lint 檢查功能,協助他們找出程式碼中的錯誤。這些類別應用於套用
java-gradle-plugin
的 Gradle 專案。它會擷取內部 Gradle 和 Android Gradle 外掛程式 API 的用途,以及急迫工作設定。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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."]]