是否可以在Android lint报告中包含Javac lint?

时间:2014-03-20 15:48:21

标签: java android gradle

使用./gradlew lintDebug生成Android lint报告时,报告中不会包含弃用或未检查转化等javac lint错误。

我目前只是在编译时启用这些javac选项:

(build.gradle)
tasks.withType(Compile) {
    options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

但问题是错误消息被发送到控制台,而不是发送到lint报告。

这真是一件小事,但如果所有的棉绒都出现在同一个地方,那就太好了。

我当前的lintDebug输出:

$ ./gradlew lintDebug
:<Project Name>:preBuild
:<Project Name>:preDebugBuild
:<Project Name>:checkDebugManifest
:<Project Name>:preReleaseBuild
:<Project Name>:prepareFrAvianeyFacebookAndroidApi370Library
:<Project Name>:prepareDebugDependencies
:<Project Name>:compileDebugAidl
:<Project Name>:compileDebugRenderscript
:<Project Name>:generateDebugBuildConfig
:<Project Name>:mergeDebugAssets
:<Project Name>:generateDebugResValues UP-TO-DATE
:<Project Name>:generateDebugResources
:<Project Name>:mergeDebugResources
:<Project Name>:processDebugManifest
:<Project Name>:processDebugResources
:<Project Name>:generateDebugSources
:<Project Name>:compileDebugJava
/path/to/some/File.java:136: warning: [unchecked] unchecked conversion
                Iterator<String> keyIterator = errors.keys();
                                                          ^
  required: Iterator<String>
  found:    Iterator
1 warning
:<Project Name>:compileLint
:<Project Name>:lintDebug
Wrote HTML report to file:/path/to/lint-results-debug.html
Wrote XML report to /path/to/lint-results-debug.xml

BUILD SUCCESSFUL

Total time: 3.936 secs

我的lint-results-debug.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<issues format="4" by="lint 22.6.1">
     <issue id="IconDensities" /> <!-- Along with the information about the IconDensities lint -->
</issues>

1 个答案:

答案 0 :(得分:0)

目前无法做到这一点。

一旦Android插件与Java插件兼容,您就可以运行其他提供Gradle插件的静态分析工具(findbugs,pmd等...)。不过,这将在他们自己的报告中。