Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scoverage 7.0.0 plugin fails checkScoverage call with java.lang.AbstractMethodError #173

Open
pra91 opened this issue Oct 1, 2021 · 3 comments

Comments

@pra91
Copy link

pra91 commented Oct 1, 2021

When using 7.0.0 of the plugin I am unable to run checkScoverage in my builds.

running ./gradlew checkScoverage runs my test cases but then fails with the following stacktrace. Running reportScoverage works as expected

Caused by: java.lang.AbstractMethodError
        at org.scoverage.ScoveragePlugin$_configureCheckTask_closure8$_closure46$_closure47.doCall(ScoveragePlugin.groovy:349)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.doExecute(AbstractTask.java:681)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.lambda$execute$0(AbstractTask.java:668)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication.reapply(DefaultUserCodeApplicationContext.java:86)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:668)
        at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:643)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:494)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
...

Gradle file:

plugins {
    id 'scala'
    id 'java-library'
    id 'com.github.johnrengelman.shadow' version '6.1.0'
    id 'cz.alenkacz.gradle.scalafmt' version '1.16.2'
    id "org.scoverage" version "7.0.0" 
    id 'io.github.cosmicsilence.scalafix' version '0.1.9'
    id "com.google.protobuf" version "0.8.16"
}
...


ext {
    scalaVersion = "2.12"
    sparkVersion = "3.1.1"
    deltaVersion = "1.0.0"
    akkaVersion = "2.6.8"
    akkaHttpVersion = "10.2.3"
    scalapbVersion = "0.11.0"
}
...


dependencies {

    compileOnly "org.scala-lang:scala-library:2.12.10"
...
    testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.2"
    testImplementation "org.scalatestplus:junit-4-13_${scalaVersion}:3.2.2.0"
    testImplementation "org.mockito:mockito-scala-scalatest_${scalaVersion}:1.16.29"
}

scoverage {
    check {
        minimumRate = 0.5
    }
}

scalafix {
    configFile = file("./.scalafix.conf")
    ignoreSourceSets = ["scoverage"]
}
@eyalroth
Copy link
Contributor

eyalroth commented Oct 2, 2021

When using the syntax for multiple checks, one has to specify the coverage type:

scoverage {
    check {
        minimumRate = 0.5
        coverageType = CoverageType.Statement
    }
}

If no multiple checks are required, then it is possible to specify just the minimum rate:

scoverage {
    minimumRate = 0.5
}

If the problem still persists after fixing the syntax, please add the output ./gradlew --version as well.

@pra91
Copy link
Author

pra91 commented Oct 2, 2021

I am still having the same problem with

scoverage {
    minimumRate = 0.5
}

gradle output below:

------------------------------------------------------------
Gradle 6.8
------------------------------------------------------------

Build time:   2021-01-08 16:38:46 UTC
Revision:     b7e82460c5373e194fb478a998c4fcfe7da53a7e

Kotlin:       1.4.20
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          1.8.0_302 (Amazon.com Inc. 25.302-b08)
OS:           Mac OS X 11.6 x86_64

@eyalroth
Copy link
Contributor

eyalroth commented Oct 9, 2021

I was able to reproduce the issue and it seems to be a problem with moving from Gradle 6 to 7.

Running a sample project with Gradle 6.8 and AdoptOpenJDK 11 yields the error:

Caused by: java.lang.AbstractMethodError: Receiver class org.scoverage.ScoverageExtension$CheckConfig does not define or inherit an implementation of the resolved method 'abstract java.lang.Object getProperty(java.lang.String)' of interface groovy.lang.GroovyObject.
        at org.scoverage.ScoveragePlugin$_configureCheckTask_closure8$_closure46$_closure47.doCall(ScoveragePlugin.groovy:343)

Upgrading to Gradle 7 in the project resolves the issue; alternatively, using the plugin version before 6 also seems to resolve the issue.

It looks like moving the plugin to be built with Gradle 7 instead of 6, which was included in version 6 of the plugin (see diff between 5 and 6), broke the plugin for builds with Gradle version less than 7.

This looks to be a problem with Gradle as can be seen in other plugins here and here.

I'll see about opening a ticket in the Gradle repository. For now, @pra91, can you upgrade your Gradle to 7 and see if it helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants