1

I have searched a lot and all the questions and answers were about excluding a specific package structure.

I have a project with src/main/java and src/test/java and src/generated/java directories.

Contents of main and generated are compiled into same directory.

Is there any way to exclude files in src/generated/java/ files from jacoco plugin source set?

Amir Pashazadeh
  • 6,654
  • 2
  • 32
  • 59

1 Answers1

0

Maybe something like this :

jacocoTestReport {
    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it, exclude: '**/Q*')
        })
    }
}

If it's not enough (some classes from src/main/java begin with Q), maybe try to override the querydsl.prefix property which default value is Q, with something more unique.

ToYonos
  • 14,576
  • 2
  • 40
  • 62
  • If you look at https://docs.gradle.org/current/dsl/org.gradle.testing.jacoco.tasks.JacocoReport.html#org.gradle.testing.jacoco.tasks.JacocoReport:sourceDirectories there is a sourceDirectories property in JacocoReport class. But I don't know how to configure it in Gradle build file. – Amir Pashazadeh Mar 10 '18 at 11:02