Skip to content

scoverage plugin not working for project iwht mix of java and scala code #102

Open
@paramr

Description

@paramr

When scala code references java code and scoverage is used with gradle, I get compilation errors in scala where the java classes are referenced.

this is because in ScoveragePlugin.groovy, we dont copy over java files from the sourceset when creating instrumentedSourceSet (Might be better to copy whole sourceset if possible:

        def instrumentedSourceSet = project.sourceSets.create('scoverage') {

            resources.source(originalSourceSet.resources)
            scala.source(originalSourceSet.scala)

            compileClasspath += originalSourceSet.compileClasspath + project.configurations.scoverage
            runtimeClasspath = it.output + project.configurations.scoverage + originalSourceSet.runtimeClasspath
        }

workaround for now is to add following to build.gradle:

allprojects {
    afterEvaluate { project ->
        def originalSourceSet = project.sourceSets.getByName(
            SourceSet.MAIN_SOURCE_SET_NAME)
        def scoverageSourceSet = project.sourceSets.getByName('scoverage')
        scoverageSourceSet.java.source(originalSourceSet.java)
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions