I am trying to set up a gradle build script for a multiproject grails application.
I have used the grails-gradle plugin and got it up and running to create a new application.
However, I have some problems when I want to convert an existing grails multiproject application to use gradle.
I have declared all subprojects in my settings.gradle file as follows:
include 'core',
//Plugins
'plugin1',
'plugin2'
and for each subproject set up its dependencies in their own build.gradle files. e.g.
plugin1 is dependent on plugin2 so I have declared the following in plugin1’s build.gradle file:
dependencies {
compile project(':plugin2')
}
However, I got the following error when I try to run the gradle test command:
UNRESOLVED DEPENDENCIES
What went wrong:
Execution failed for task ‘:plugin1:test’.
Cause: Could not resolve all dependencies for configuration ‘:plugin1:runtime’:
– unresolved dependency: {}#plugin2;1.5-SNAPSHOT: configuration not found in {}#plugin2;1.5-SNAPSHOT: ‘default’. It was required from {}#plugin1;1.5-SNAPSHOT compile
My question is then, How do I set up the subproject dependencies in gradle?
I have declared them in each subprojects BuildConfig.groovy as inline dependencies, do I have to declare them in gradle as well?
I answer my own question If anyone else have the same issue.
I wanted to set the build order for a multiproject grails application (A main application that was dependent on several grails-plugins located in separate folders).
I ended up by declaring a
dependsOn()in each subproject buildfile.Example:
My main application is dependent on pluginA and pluginB. PluginB is dependent on PluginC
In my root
build.gradleI declared:and in my root
settings.gradleI declared:In pluginB:s build.gradle file I declared
That solved my issue. However it also introduced another issue that the the tests for each plugin were compiled but not executed.
I found a solution for this @ GRAILS-7296
I created a
_Events.groovyfile in thescriptsfolder for each subproject and included:This solved all my problems and I have now a multiproject-grails application that uses Gradle for the build.