【问题标题】:Single lint report in multi-modular Android project多模块 Android 项目中的单个 lint 报告
【发布时间】:2018-04-02 16:06:59
【问题描述】:

有谁知道在多模块 Android 项目中是否可以有一个用于 Lint 检查的 Gradle 任务? 目的是为所有模块(应用程序 + 一些 Android 库)提供唯一一份 HTML/XML 报告。

【问题讨论】:

    标签: gradle android-gradle-plugin lint


    【解决方案1】:

    为此,仅在使用其他模块作为依赖项的模块中配置 android lint,并在 lintOptions 中启用 checkDependencies

    例如:

    有一个名为app的应用程序模块使用feature_1feature_2feature_3库模块作为依赖项,所以在lintOptionslintOptions模块@987654332中将checkDependencies设置为true @文件。

    android{
    
        lintOptions{
    
            checkDependencies true // <---
            xmlReport false
            htmlReport true
            htmlOutput file("${project.rootDir}/build/reports/android-lint.html")
    
        }
    }
    

    注意

    当您运行 ./gradlew lint 时,这将为每个模块 build/reports 目录中的每个依赖模块生成报告,但是将在指定位置生成与项目相关的所有 lint 问题的报告。


    参考:https://groups.google.com/d/msg/lint-dev/TpTMBMlwPPs/WZHCu59TAwAJ

    【讨论】:

    • 请注意,合并报告的 lint 速度要慢得多,正如 google 小组讨论中所指出的那样:“lint 速度较慢,因为对共享模块进行了多次分析”
    • 感谢这些参数!我设置了xmlReport = false htmlReport = false 并在终端中收到了所有警告。因为我有很多模块,所以我在一个地方得到了所有警告,而不是在许多 HTML 文件中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 2011-04-15
    • 1970-01-01
    • 2022-06-14
    • 2013-12-03
    • 1970-01-01
    相关资源
    最近更新 更多