I have grails 3.3.9 installed on Mac.
If I create a normal application, e.g. using:
grails create-app myapp
I can create domain classes, views etc, run the app and see the web pages.
However, I need two different web apps (one for the internal backoffice, and one for the customer facing public website). The solution is to create a core plugin which contains only the domain objects and service layer which is then called by the two web apps, and later API apps etc. also.
I followed the official instructions here
i.e.:
$ grails create-plugin core --profile=plugin --features=hibernate5,events
$ Grails create-app myapp
$ create settings.gradle with: include "myapp","core"
$ edit build.grandle of myapp and add:
grails {
plugins {
compile project(':core')
}
}
Now when I try to compile either, or run any grails command (such as grails create-service) I get this:
| Resolving Dependencies. Please wait...
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/me/dev/grails_projects/tst/core/build.gradle' line: 17
* What went wrong:
A problem occurred evaluating project ':core'.
> Failed to apply plugin [id 'org.grails.grails-plugin']
> Could not find method runtimeOnly() for arguments [io.methvin:directory-watcher] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
If I remove the settings.gradle, I can compile the plugin. If I add it back, compile (or any grails command such as create-domain-class) fails with the above error.
Here is the build.gradle:
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
}
}
version "0.1"
group "core"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"org.grails.grails-plugin"
apply plugin:"org.grails.grails-plugin-publish"
The offending line 17 is:
apply plugin:"org.grails.grails-plugin"
I also tried creating the plugin with the name "corex" instead of core just in case that was a reserved word. Got same results - plugin wont compile.
Note, the project directory structure looks like this:
settings.gradle
myapp
build.gradle
etc.
core
build.gradle.
etc.
I also tried several variations of the line in settings.gradle, including:
- include 'myapp', 'core'
- include 'core', 'myapp'
- include ":myapp", ":core"
Any ideas?
UPDATE 1
I just tried this with 3.3.8 and it seems to work. So it would appear to be a bug in 3.3.9 which prevents using modular apps.
