How to prevents duplicate plugins?

(Horcrux7) #1

I receive the follow error message:

A problem occurred evaluating script.
> Failed to apply plugin [class '']
   > Cannot add extension with name 'download', as there is an extension already registered with that name.

The cause is that we apply 2 different script plugins which apply the same plugin. The structure is like:

  apply from: "util1.gradle"
     apply plugin:
  apply from: "util2.gradle"
     apply plugin:

In the normal case we use only one of the both utils.gradle. But now we have a case in which we need both. Can we prevent the duplicate registration through adding a dependency if the plugin already exists?

(Horcrux7) #2

The solution is to change the apply plugin line to:

if( !project.plugins.hasPlugin( '' ) ) apply plugin:

(Chris Doré) #3

From what I understand, the Gradle plugin management code is supposed to take care of this for you. Perhaps this is a bug.