vanniktech/gradle-android-junit-jacoco-plugin

excluded variants break build

passsy opened this issue · 3 comments

The plugin adds dependencies for tasks of build types which are excluded and therefore not found.

android {
    ...
    variantFilter { variant ->
        if (variant.name == "debug") {
            variant.setIgnore(true)
        }
    }
}

Results in:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:jacocoTestReportDebug'.
> Task with path 'testDebugUnitTest' not found in project ':app'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

I guess the fix is to check for that case right? Basically look if the variant is being ignored or not.

The jacocoTestReport<variantName> shouldn't be added for ignored variants, most likely solvable with a single if (variant.isIgnored()) return.

Sorry, haven't had the time to dig into this plugin and send a PR or give clearer instructions of what's missing.

That's ok. It should be pretty easy to fix.