Error Resolving configuration 'apiElements' directly is not allowed

Hi guys,

I’m new in the Gradle world and I’m writing my personal plugin for Gradle.

And I have some problem with using my plugin into another project when I run the task of my personal plugin I have this error

vincenzo@vincenzo ~/Desktop/guide-gradle-intro/tmp $ gradle createDatabase
:createDatabase FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':createDatabase'.
> Resolving configuration 'apiElements' directly is not allowed

I think that the error is for my dependency in the build.gradle the plugin, but I do not find the error.

This is my code in the repo GitHub

Sorry for my terrible English but I’m learning

Not every configuration is resolvable (configuration.isCanBeResolved()), but you’re iterating through every Configuration in the project and trying to resolve it on CreateDatabaseTask.java - line 54.

At the very least, you should check to see if a configuration can be resolved before you try to resolve it if you didn’t create it. However, forcing all configurations to be resolved just to find a jar with a name is not good practice. It would be much more acceptable to provide a configuration that you must add the driver dependency to so that you can only resolve exactly what you need.

1 Like

Thanks for your help and your answer, you give me some example for resolve [this problem]?(Add dependence of the project into my custom plugin)