grails 3.3.9, plugin wont compile after adding the settings.gradle

Viewed 1867

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:

  1. include 'myapp', 'core'
  2. include 'core', 'myapp'
  3. 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.

1 Answers

Since this is the first Google link by "Could not find method grailsPublish() for arguments" request I'll post the answer for this related issue here.

With Grails 4.0.12 when you've just created a plugin you won't be able to use Gradle commands like ./gradlew run-app. It will fail with the mentioned error message ^.

And the reason is because Grails team broke the publishing plugin: https://giters.com/grails/grails-core/issues/12007

So to make your newly created project work you need to open build.gradle and comment/remove grailsPublish { section: enter image description here

Related