Internal configuration for a custom gradle plugin


First, thanks for read me. I have created a new gradle plugin and now I would like to have the gradle internal configuration in the plugin build.gradle. For example with a closure, in order to set the plugin configuration dependencies.

For example:

internalPluginConfig {
   dependencies {
   compile {
   runtime {


The idea is to set these dependencies in the apply method of the custom plugin.

For example:

DependencySet dependencies = project.configurations.customPluginRuntime.dependencies
internalPluginConfig.dependencies.runtime.each {
   dependencies << project.dependencies.create("${it}")

And not:

DependencySet dependencies = project.configurations.customPluginTest.dependencies
dependencies << project.dependencies.create('dep:dep:12')
dependencies << project.dependencies.create('dep:dep:13')

The first approach that I think was with a custom extension, but I think that the extension could be used by the plugin consumer…

Would you have any idea how to do it?

Thanks in advance.

Would something like this work?

    configurations {    
    dependencies {
        internalPluginCompileConfig 'dep:dep:11'
        internalPluginRuntimeConfig 'dep:dep:12'
        internalPluginRuntimeConfig 'dep:dep:13'

Thanks for the response! This is a good idea yes!

At this point I think that I need to expand the problem context.

The idea is when the plugin consumer adds the plugin to their build.gradle, these dependencies (that are defined by default in the plugin) will be download in the consumer project.

In the first approach that run ok is setting this dependencies in the apply() method of the main plugin class. But I think that have the dependencies hardcoded in the class It’s not a good practice.

That is the point because I would like to have these dependencies defined in the build.gradle or in a config file (for example).

Trying your approach I see that the dependencies are only downloading in the plugin project, but not in the plugin consumer.

Another thing is that if try to get this config info in the plugin main class in the apply() method I have an error:

Could not get unknown property 'internalPluginCompileConfig' for configuration container of type