Cannot apply both java and play plugins

Applying both java and play plugins will get the following error:

Failed to apply plugin [class ‘org.gradle.api.plugins.BasePlugin’]
Cannot add a configuration with name ‘default’ as a configuration with that name already exists.

I know people don’t normally need to apply both of them. But in our use cases, we have many of our own plugins which would also apply java plugin automatically. And I have to apply them to my play projects. Can this problem be fixed?

To reproduce, a simple build.gradle file:
apply plugin: ‘play’
apply plugin: ‘java’

Then just run gradle

Hmm, I think you’re seeing a variation of this: Plugin google-test causes failure when plugin java is applied and a general problem with mixing plugins and rule-based plugins together.

This works around the issue:

task check {}
apply plugin: 'java'
apply plugin: 'play'

I’ve raised GRADLE-3356

FYI, in my real world use-case, I am not applying java plugin directly. I am applying a custom plugin which in turn applies java plugin. So when I use the workaround, I get the following:

  • What went wrong:
    A problem occurred evaluating project ‘:xyz’.

Failed to apply plugin [class ‘org.gradle.language.base.plugins.ComponentModelBasePlugin’]
Cannot create ‘components’ using creation rule ‘ComponentModelBasePlugin.apply()’ as model element ‘’ is no longer mutable.