Plugins in a Multiproject fails at Grails 3.2.11

219 Views Asked by At

Configuration

Following the Plugins and Multi-Project Builds section at the Grails 3.2.11 manual, its suppose that I can setup a Multi-project with the next commands in a terminal:

echo "Creating the root folder..."
mkdir test-multi-project
cd test-multi-project

echo "Creating the settings.gradle file..."
echo "include 'myapp', 'myplugin'" >> settings.gradle

echo "Creating the Grails application..."
grails create-app myapp

echo "Creating the Grails plugin..."
grails create-plugin myplugin

echo "Configuring the dependency between the application and the plugin..."
echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle 

echo "Executing the Grails application..."
cd myapp
grails run-app 

Error

However, when I tried those commands for create and configure the Grails Application and the Plugin the grails run-app command throws next error:

FAILURE: Build failed with an exception.

* Where:
Build file '~/test-multi-project/myapp/build.gradle' line: 61

* What went wrong:
A problem occurred evaluating root project 'myapp'.
> Project with path ':myplugin' could not be found in root project 'myapp'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

CONFIGURE FAILED

Total time: 4.835 secs
| Error Error initializing classpath: Project with path ':myplugin' could not be found in root project 'myapp'. (Use --stacktrace to see the full trace)

Additional Information

I already tested the above commands using Grails 3.2.8, 3.2.9, 3.2.10 and 3.2.11 and the code throws the same error.

On the other hand, I tested the above commands using Grails 3.2.3, 3.2.5, and 3.2.7 and the project is executed fine. Also, the Grails landing page shows that 'mypluin' is been used by the application.

Note, I am using sdk to handle the Grails versions. The commands were executed using Java 1.7 and Yosemite:

  • Groovy: 2.4.7
  • Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
  • JVM: 1.7.0_141 (Azul Systems, Inc. 24.141-b11)
  • OS: Mac OS X 10.10.5 x86_64

Question:

I am wondering what else I need to do or what I am doing wrong in order to make this code works on Grails 3.2.11

Thanks in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

Jeff Brown fixed the above issue removing the multi-project-test2/myapp/settings.gradle file and adding the next line to the multi-project-test2/settings.gradle file:

project(':myapp').name = 'myapp'

As you can see at the next GitHub's commit: https://github.com/esalomon/multi-project-test2/commit/d92c3fbc67156bcd1af9f47dc6f2984534154bad

After the above updated the multi-project-test2 can be downloaded and it will work fine.

4
On

It is likely to have gone wrong at around this point:

echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle 

That segment needs to be added to existing block of that file not a new block (not that I have tested)

What happens when you follow the steps manually ? does it work that way and if so have you thought of doing a diff across files that changes to see what is different.

You are providing the script which is great and maybe someone else wishes to run through it but i suspect it is what has already been pointed out.

You should look into ed Something like this example:

I am using a grails 3.2.8 app which in the dependency segment ends like this:

   runtime "com.h2database:h2"
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"

Now if I execute

test328$ ed -s build.gradle <<EOF >/dev/null
g/^    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
a
compile project(':myplugin') 
.
w
q
EOF

you can now see:

tail -n20 build.gradle 
    runtime "com.h2database:h2"
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
compile project(':myplugin') 
}

The new entry added on. You will need to find a pointer in your existing file generated by grails and use like above that pointer to add your entry

The ed script was used to demo this since obviously it wasn't clear enough previously