【问题标题】:Maven Clover Instrumentation error - unexpected tokenMaven Clover Instrumentation 错误 - 意外令牌
【发布时间】:2018-08-10 10:34:33
【问题描述】:

我们正在使用在 Google Cloud Platform 中运行的 eclipse 和 maven 构建 Java servlet 应用程序。

我们开始考虑将 OpenClover 集成到我们的构建中,以提供测试覆盖率和代码复杂度统计数据。

我们的一些应用依赖于 Google 库,例如 com.google.cloud.spanner.Statement.Builder。 当我们尝试从命令行对这些 servlet 运行 clover 时,我们会看到以下错误:

[INFO] Building auditio 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ auditio ---
[INFO]
[INFO] --- clover-maven-plugin:4.3.0:setup (default-cli) @ auditio ---
[INFO] OpenClover Version 4.3.0, built on August 03 2018 (build-1010)
[INFO] Creating new database at 'C:\.......\service\auditio\target\clover\clover.db'.
[INFO] Processing files at 1.8 source level.
[INFO] C:\...........\service\auditio\AuditIoSpanner.java:54:5:unexp
ected token: builder
[INFO] Instrumentation error
com.atlassian.clover.api.CloverException: C:\...............\service\auditio\src\main\java\com\mandm\service\aud
itio\AuditIoSpanner.java:54:5:unexpected token: builder
        at com.atlassian.clover.instr.java.Instrumenter.instrument(Instrumenter.java:159)
        at com.atlassian.clover.CloverInstr.execute(CloverInstr.java:76)
        at com.atlassian.clover.CloverInstr.mainImpl(CloverInstr.java:54)


[ERROR] Failed to execute goal org.openclover:clover-maven-plugin:4.3.0:setup (default-cli) on project auditio: Clover has fa
iled to instrument the source files in the [C:\........service\auditio\target\clover\src-instrumented] d
irectory -> [Help 1]

这是在运行以下命令时:

mvn clean clover:setup test clover:aggregate clover:clover check

在我们的 pom.xml 中包含以下内容

<plugin>
    <groupId>org.openclover</groupId>
    <artifactId>clover-maven-plugin</artifactId>
    <version>4.3.0</version>
    <configuration>
        <targetPercentage>75%</targetPercentage>
    </configuration>
    <executions>
        <execution>
            <phase>verify</phase>
                <goals>
                    <goal>instrument</goal>
                    <goal>check</goal>
                </goals>
        </execution>
    </executions>
</plugin>

我们正在运行 JDK 1.8。

虽然我们可以排除包含这些引用的有问题的类文件以使三叶草覆盖起作用,但这并不理想。 没有这些特定引用的 Servlet 可以正常运行 clover。

谁能告知为什么会发生这种情况以及是否有已知的解决方案?

提前致谢。

【问题讨论】:

  • 如果没有代码 sn-p 展示 Clover 无法检测的内容,就不可能知道发生了什么。但胡思乱想。由于存在“构建器”引用,因此可能是您正在使用的 Lombock 或其他代码生成工具导致 Clover 出现问题。作为旁注,您可以关闭特定代码行的检测 //CLOVER:OFF //CLOVER:ON confluence.atlassian.com/clover/…

标签: java maven token clover


【解决方案1】:

在联系 OpenClover 支持后,他们确认这是由他们最新 (4.3.0) 版本中的错误引起的,可以在此处看到 - https://bitbucket.org/openclover/clover/issues/72 - 并将在补丁中解决。

【讨论】:

    猜你喜欢
    • 2011-12-20
    • 2015-11-19
    • 2018-08-27
    • 2014-12-07
    • 2016-08-10
    • 2013-02-11
    • 2013-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多