0
votes

Is it possible to make one custom plugin in Grails 3 dependent on another custom plugin? Here's my project structure:

  • grails3-home
    • myApp
    • customPlugin1
      • build.gradle
      • settings.gradle
    • customPlugin2 ...

I would like to make customPlugin1 dependent on customPlugin2. Everything I've read says this possible with multi-project builds between apps and plugins in Grails 3. And I'm able to declare both plugins as dependencies in myApp with no issues. However, I have not been successful in getting this to work between the two plugins.

I have added the following line to customPlugin1 > settings.gradle

include "customPlugin2"

And to customPlugin1 > build.gradle

grails {
    plugins {
        compile project(':customPlugin2')
    }
}

However when I try to build customPlugin1, I get the following error:

FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring root project 'customPlugin1'.

    Could not resolve all dependencies for configuration ':runtime'. Project : declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :customPlugin2.

Is anyone aware if what I'm trying to do is possible, and if so, what I might be missing?

Update: If I change my configuration to

include "../customPlugin2"

and

grails {
    plugins {
        compile project(':../customPlugin2')
    }
}

the plugin builds successfully, but I am no longer able to import domains classes from customPlugin2 into customPlugin1 domains classes

1

1 Answers

0
votes

You should do the include in the root settings.gradle

include 'myApp', 'customPlugin1', 'customPlugin2'

Then in plugin 1:

grails {
    plugins {
        compile project(':customPlugin2')
    }
}

Note that this simply defines a dependency. If you need plugin 2 to load before or after plugin 1 you need to define that as well in the plugin descriptor.