无法让 Coverity Scan 工作(Windows 和 Travis 上的 Java/Kotlin/Gradle 3.3)



更新:请参阅Caleb的答案中的解决方案

我真的很努力地让Coverity为我的构建工作,但到目前为止几乎没有成功。

第一个细节:

  • 我的项目是普通的java库(没有web或花哨的容器),很少有只编译的依赖项,使用Gradle构建
  • 生产代码是用Java和Kotlin编写的
  • 完整的项目可在github上获得:https://github.com/ddimtirov/nuggets
  • 在Coverity Scan上:https://scan.coverity.com/projects/ddimtirov-nuggets?tab=project_settings
  • 我的开发环境是Windows 10、Java 1.8.0_92、Gradle 3.3、CMD shell(尽管我也尝试过Cygwin和Mingw-Bash)
  • 还有Travis在Linux上的构建

我首先从以下位置下载了一个软件包:https://scan.coverity.com/download/java/win64

然后,我将bin目录添加到我的路径中,转到我的项目根目录并运行以下命令。

$ set PATH=%PATH%;C:Usersdimitsandboxcov-analysisbin
$ gradlew clean
$ cov-build --dir cov-int gradlew jar

前2个如预期,最后一个-没有那么多:

Coverity Build Capture (32-bit) version 8.7.0 on Windows 10 Professional, 64-bit (build 14393)
Internal version numbers: b452b3f2c8 p-lodi-push-28091.612
The system cannot execute the specified program.
[WARNING] Build command gradlew.bat jar exited with code 1. Please verify that the build completed successfully.
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
C:/Users/dimit/sandbox/nuggets/cov-int/build-log.txt

我已将构建日志放在此处:https://gist.github.com/ddimtirov/9daa0e9f1f0954453f01fcec42ae2198

说明页面上的"构建失败疑难解答"指向一个论坛索引页面,该页面毫无帮助:https://software-community-synopsys.force.com/s/#4838

接下来,我想如果我只能以其他方式生成数据,我可以将其上传到扫描服务,从而绕过这个问题。我发现https://github.com/mjdetullio/gradle-coverity-plugin

Gradle Coverity插件发出了数据,但当我将其压缩并上传到扫描服务时,它弹出了错误电子邮件。

作为最后的手段,我尝试了TravisCI集成——经过几次尝试,我完成了它,没有出现任何错误,但它似乎没有上传任何东西。。。

https://travis-ci.org/ddimtirov/nuggets/builds/196307253https://scan.coverity.com/projects/ddimtirov-nuggets?tab=overview

我快要放弃了(顺便说一句,没有在线文档没有帮助)

问题1-"系统无法执行指定的程序。">

出现此问题是因为使用了Windows 32位工具包来尝试捕获Windows 64位内部版本。尝试将32位进程附加到64位进程会导致执行失败。

  • 这里的解决方案是将Coverity二进制文件的比特率与您的平台的比特率相匹配(使用Windows 64位工具包)

问题2-在Linux上捕获TravisCI构建失败

这个问题似乎是由于Coverity的Java Capture和ErrorProne插件之间的不兼容,构建日志中的消息证明了这一点:

WARNING: Failed load class file java/io/FileNotFoundException.class as a resource using the class loader net.ltgt.gradle.errorprone.ErrorProneCompiler$SelfFirstClassLoader@36358417
  • 这里的解决方案是为Coverity构建禁用该插件

Varia

  • 在调试该问题时,讨论了Gradle守护进程干扰Coverity的已知问题,但最终与该问题无关
  • 注意到"prepend"命令的问题是用户错误;prepend命令不是一个单独运行的命令,它用于实用程序目的

需要注意的几点,因为阅读我们的文档对于成功使用我们的工具至关重要:

  1. Kotlin不支持
  2. 需要为您的平台使用适当的二进制文件(因此在64位平台上使用win32二进制文件通常不起作用)

最新更新