0

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.

esalomon
  • 85
  • 1
  • 12

2 Answers2

1

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.

esalomon
  • 85
  • 1
  • 12
0

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

V H
  • 8,382
  • 2
  • 28
  • 48
  • I am afraid that I am not following what are you trying to say. For clarification, instead of use the `echo "grails { plugins { compile project(':myplugin') } }" >> myapp/build.gradle` command you can open the `myapp/build.gradle` and add the closure definition to configure the plugin. – esalomon Jul 15 '17 at 23:09
  • right but I was trying to guide you in using ed to automate that part and since it didn't make sense to you I have updated the answer with it is exactly that you need to do - obviously change :htmlunit:2.18" all that and even the actual line to match the line you wish to add entry to add extra spaces on the line after a to match your file etc – V H Jul 16 '17 at 09:09
  • the closure already exists so you are appending existing closure rather than adding a new block does the documentation state that you should add an entirely new closure or when you add a new plugin do you then create a new closure per plugin or do you append the existing block can you not see where you have gone wrong as yet? – V H Jul 16 '17 at 09:11
  • Okay, first about all, thanks a lot for your response. Second I research a little more about this, and now I understood more about what are you are saying. However, it seems that this response is not answering the question. Here is the thing, the echo command is creating a grails section for the plugin reference, this is valid according with the grails documentation. As you said, there is a dependencies section already in the file. There are differences if the dependency is placed there, in spite of that, I already tried placing the plugin reference there, and it did not work. – esalomon Jul 17 '17 at 18:41