Plugin google-test causes failure when plugin java is applied

Simply add the java plugin to the google-test sample code as follows.

    apply plugin: 'cpp'
    apply plugin: 'google-test'
    apply plugin: 'java'

The gradle build shows the following error messages.

FAILURE: Build failed with an exception.
  • What went wrong:
    A problem occurred configuring root project ‘google-test’.

Exception thrown while executing model rule: org.gradle.nativeplatform.test.plugins.NativeBinariesTestPlugin$Rules#attachBinariesToCheckLifecycle(org.gradle.model.ModelMap<org.gradle.api.Task>, org.gradle.platform.base.BinaryContainer)
Cannot add rule org.gradle.nativeplatform.test.plugins.NativeBinariesTestPlugin$Rules#attachBinariesToCheckLifecycle(org.gradle.model.ModelMap<org.gradle.api.Task>, org.gradle.platform.base.BinaryContainer) > named(check) for model element ‘tasks.check’ at state Initialized as this element is already at state GraphClosed.

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


Please explain which plugin deserves a fix. My project really needs both to be applied.

Thanks for the report. I raised GRADLE-3327

A hacky workaround for right now would be to try:

    apply plugin: 'cpp'
    apply plugin: 'google-test'
    task check() {}
    apply plugin: 'java'

This creates a ‘check’ task before the base plugin can create one.

I’m curious if there’s been any progress in this? I’m running into this issue currently, with Gradle 2.7. The hacky workaround still seems to work, but it remains a hacky workaround.