Plugins in a Multiproject fails at Grails 3.2.11 - grails

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.

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.

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

Related

Can't build basic rest-api project in Grails 3.1.0

I've just created a test project in Grails 3.1.0 that uses the new rest-api profile:
grails create-app rest-test --profile=rest-api
Without any modifications, when I try and gradle build the application the build fails:
cd rest-test
gradle build
:compileJava UP-TO-DATE
:compileGroovy
:processResources
:classes
:compileTestJava UP-TO-DATE
:compileTestGroovy UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:compileIntegrationTestJava UP-TO-DATE
:compileIntegrationTestGroovy UP-TO-DATE
:findMainClass
:buildProperties
:compileGsonViews
Invalid arguments: [C:\projects\rest-test\grails-app\views,C:\projects\rest-test\build\gson-classes\main,1.8,rest-test,C:\projects\rest-test\grails-app\conf\application.yml,UTF-8]
Usage: java -cp CLASSPATH grails.plugin.json.view.JsonViewCompiler [srcDir] [destDir] [targetCompatibility] [packageImports] [packageName] [configFile] [encoding]
:compileGsonViews FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGsonViews'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1
Looking at that error message, it seems there aren't enough arguments passed to the java call.
If I do a grails run-app I'm able to start the app successfully and can see the gson views at localhost:8080.
Does anyone have any ideas why the gradle build command is failing?
Found the solution on Grails GitHub issue tracker:
Please replace the line
classpath "org.grails.plugins:views-gradle:1.0.1"
With
classpath "org.grails.plugins:views-gradle:1.0.3"
In your build.gradle file
I tested it with Grails 3.1.2 -- it works!

Why does Grails not recognize BuildStandalone?

I have a Grails app (2.3.6) that uses the Grails Build Standalone plugin.
The myapp/grails-app/conf/BuildConfig.groovy:
plugins {
runtime ":resources:1.2.7"
compile 'org.grails.plugins:gson:1.1.4'
compile ":standalone:1.2.3"
build ":release:3.0.1"
runtime ":cached-resources:1.0"
compile ":cache-headers:1.0.4"
}
When I go to myapp and run grails build-standalone myapp.jar --tomcat I get:
$ grails build-standalone myapp.jar --tomcat
|Loading Grails 2.3.6
|Configuring classpath
|Running pre-compiled script
|Script 'BuildStandalone' not found, did you mean:
1) InstallDependency
2) Stats
3) CreateMultiProjectBuild_
4) TestApp
5) InstallPlugin
Please make a selection or enter Q to quit:
What is going on here?

Update to 2.3.9 - Error executing script RunApp: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling

I am update grails from 2.3.7 to 2.3.9 and it has error
Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling.
Here is run-app --stacktrace --verbose :
|Loading Grails 2.3.9
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
...........
|Compiling 1 source files
[groovyc] Compiling 1 source file to
Z:\future13_grails\cerp\target\classes
.....................................Error
|
Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at
org.grails.plugins.tomcat.TomcatServer.(TomcatServer.groovy:81)
at
org.grails.plugins.tomcat.InlineExplodedTomcatServer.(InlineExplodedTomcatServer.groovy)
at
org.grails.plugins.tomcat.TomcatServerFactory.createInline(TomcatServerFactory.groovy:38)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner.runInline(GrailsProjectRunner.groovy:183)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner.runApp(GrailsProjectRunner.groovy:119)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner$runApp$0.call(Unknown
Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
...
Error | Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
And here is BuildConfig.groovy
... plugins {
// plugins for the build system only
build ':tomcat:7.0.52.1'
// plugins for the compile step
compile ':scaffolding:2.0.3'
compile ':cache:1.1.1'
compile ":spring-security-core:2.0-RC2"
compile ":searchable:0.6.6"
// plugins needed at runtime but not for compilation
runtime ':hibernate:3.6.10.15' // ':hibernate4:4.3.5.3' for Hibernate 4
runtime ':database-migration:1.4.0'
runtime ":jquery:1.10.2"
runtime ':resources:1.2.8'
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0.1"
//runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
runtime ":cors:1.1.2"
} ...
I deleted target folder and run grails, it run successfully.
If deleting the target folder doesn't work for your, use the clean and compile commands before trying to run your project again.
Duplicate question Groovy ShortTypeHandling ClassNotFoundException.
I doubt any of the plugin's version is only compatible with Grails version 2.4.0 and above (which comes with Groovy 2.3.*).

Grails application using grails-gradle-plugin gets PermGen space error upon run-app

I have a multi-project gradle build that has several Grails app.
One of these app contains many artefacts (controllers, services, groovy code, etc...).
When I run it using the gradle grails-run-app command, I get the following error:
| Error Server failed to start: PermGen space (Use --stacktrace to see the full trace)
We tried to add to buildConfig.groovy the following
disable.auto.recompile=true
and add the following to the gradle.properties
-XX:MaxPermSize=1G -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
But the error remain
I am using:
Grails 2.3.1, Gradle 1.8 and grails-gradle-plugin 2.0.0-SNAPSHOT
Any ideas ?
Eduardo
Add the following lines to the begin of your gradle.build
import org.grails.gradle.plugin.GrailsTask
tasks.withType(org.grails.gradle.plugin.GrailsTask) { Task t ->
t.jvmOptions {
jvmArgs '-Xms32m -Xmx1524m -XX:PermSize=32m -XX:MaxPermSize=512m -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC'.split(' ')
}
}
It runs every grails task with the specified jvm args.
Check this link

Gradle : How to define a task that depend on an ant target

Hi if i list all tasks with gradle testGradle tasks -- all I see all imported ant tasks, but when i try to create my task that depends on an ant task, I am getting "Could not determine the dependencies of task ':testGradle'.
the line that is a problem: task testGradle(dependsOn: 'init' ) - it clearly doesn't see ant init task.
What did I do wrong?
build.gradle
println "this will always runs first"
task buildM << {
println "Importing ..."
ant.importBuild 'build.xml'
println "Done importing"
}
task testGradle(dependsOn : init ) << {
println tasks.getByPath('init').path
}
gradle tasks all
Other tasks
all
compile - Compile main source tree java files
deploy - deploy WAR file
**init** - Prepare for running compiling artifacts
....
byWorld5
copyTestConfiguration - Copy unit test configurations
deployLoggerProperties - Deploy logging.properties to tomcat
execMoped
importTasks
install - Install application in Tomcat
list - List Tomcat applications
init - Prepare for running compiling artifacts
reload - Reload application in Tomcat
start - Start Tomcat application
stop - Stop Tomcat application
test - Run junit tests
compile - Compile main source tree java files
init - Prepare for running compiling artifacts
> gradle -v
Gradle 1.1
Gradle build time: Tuesday, July 31, 2012 1:24:32 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_24 (Sun Microsystems Inc. 20.0-b12)
OS: Linux 2.6.32-220.23.1.el6.x86_64 amd64
>gradle -c
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'moped_gradle'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:463)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:75)
at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38)
at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:35)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:439)
at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:434)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:139)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:110)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:78)
at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:38)
at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:25)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:30)
at org.gradle.launcher.cli.ActionAdapter.execute(ActionAdapter.java:22)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:200)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:173)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:138)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:39)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: groovy.lang.MissingPropertyException: Could not find property 'init' on root project 'moped_gradle'.
at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:60)
at org.gradle.groovy.scripts.BasicScript.propertyMissing(BasicScript.java:70)
at build_62g86rvs7k0vqsu3ssgdsrobsc.run(/home/natalik/MyInstalls/moped_gradle/build.gradle:14)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 33 more
The ant.importBuild statement must be called during configuration phase to work.
I did it during execution.

Resources