Grails 3 scaffolding issue - grails

I'm trying to port my project from Grails 2.4 to 3.0. Nothing fancy: 12 Domains, 13 Controllers and a service.
Everything works fine, except when I try to include the Scaffolding plugin. I literally follow the manual here, but the syntax must be wrong. Adding the plugin line as specified:
plugins {
…
compile ":scaffolding:2.0.0"
…
}
leads to this:
BUILD FAILED
Total time: 1.559 secs
| Error Error initializing classpath: startup failed:
build file 'E:\GrailsIdeaProjects\HcaServer\build.gradle': 17: only id(String) method calls allowed in plugins {} script block
See http://gradle.org/docs/2.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
# line 17, column 5.
compile ":scaffolding:2.0.0"
^
1 error
(Use --stacktrace to see the full trace)
Somebody knows the right syntax to include the Scaffolding plugin in Grails 3?
EDIT: Thanks to Casey for pointing me in the right direction: Scaffolding plugin is actually already included in default build.gradle. Anyway, i still get a webpage like this on every controller:
Error: Page Not Found (404)
Path: /*controllerName*/index
I've been using the same syntax as per the manual, declaring a static scaffold = true on each controller. Why do I get a 404 page then? I do have index.gsp, error.gsp and notFound.gsp in my views folder.

It looks like that documentation hasn't been updated for Grails 3.0 yet. Your build.gradle file should have a dependencies block, where you can specify the dependency:
dependencies {
// ...
runtime "org.grails.plugins:scaffolding"
}
You can also see this by creating a new app using Grails 3.0 and checking out the default build.gradle file.

After researching for a while, turns out dynamic scaffolding hasn't made it yet into Grails 3:
https://groups.google.com/forum/m/#!topic/grails-dev-discuss/6R2YaF96Uts

Try this, It works for me.
dependencies {
compile "org.grails.plugins:scaffolding"
}
I am using grails 3.09.

Related

Upgrading Grails from v3.0 to v3.1 or v3.2

I'm in process of upgrading an app from Grails v2 to v3 .
I got to a point where it works reasonably well with Grails 3.0.17.
I wanted to upgrade it to v3.1 or v3.2. But after changing the version in gradle.properties that's what I get after executing grails run-app:
me#host:[~/](feature/grails3-migration) : grails run-app
| Error Error occurred running Grails CLI: startup failed:
script14867378818131525390840.groovy: 3: unable to resolve class xxx.yyy.CollectorsJob
# line 3, column 1.
import xxx.yyy.jobs.CollectorsJob
^
script14867378818131525390840.groovy: 6: unable to resolve class xxx.yyy.domain.business.Company
# line 6, column 1.
import xxx.yyy.domain.business.Company
^
script14867378818131525390840.groovy: 5: unable to resolve class xxx.yyy.domain.access.User
# line 5, column 1.
import xxx.yyy.domain.access.User
^
...
There's about 15 errors like that printed.
What's the problem here? I've tried clear the project and change the jdk version fro 1.8 -> 1.7. Each time the same result.
If you are referencing application classes in grails-app/conf/application.groovy these will need to be moved to your runtime configuration in grails-app/conf/runtime.groovy
The application.groovy file is parsed by the build system in addition to the runtime so cannot contain references to classes that are not yet compiled

Gradle cannot find plugin

I have the following in my build.gradle of my Grails 3 project.
dependencies {
...
compile "org.grails.plugins:spring-security-core:3.0.3"
// The following line was the true cause of my problem
compile("org.grails.plugins:spring-security-oauth-google:0.3.1")
...
}
Now when I run Gradle I get this error:
Error Error initializing classpath: Could not find spring-security-core.zip (org.grails.plugins:spring-security-core:3.0.3).
Searched in the following locations:
https://repo.grails.org/grails/core/org/grails/plugins/spring-security-core/3.0.3/spring-security-core-3.0.3.zip (Use --stacktrace to see the full trace)
If I go to the specified path I do see the plugin but just as reported there is no zip file.
What am I doing wrong here?
The root for this problem I found in a little bit different place than expected.
I am working on upgrading a Grails 2.5 project to Grails 3 and I had lead myself on a wrong track. I needed to include spring-security-oauth-google and when it did not work as expected I also included spring-security-core which then derailed me.
The cause of this problem is dependencies being loaded from dependencies I have in my own project. In order to avoid loading those dependencies - called transitive dependencies - the following has to be done:
plugins {
compile "org.grails.plugins:spring-security-core:3.0.3"
compile("org.grails.plugins:spring-security-oauth-google:0.3.1") {
exclude group: 'org.grails.plugins', module: 'spring-security-core'
}
}
This will load the spring-security-core 3.0.3 correctly ignoring the dependency from spring-security-oauth-google.

Grails-Camel Plugin won't install or run

Please note: Although this question involves a lib called Apache Camel I really think this is just a question about how modern Grails plugins work.
I am on Grails 2.4.2 here, and I am trying to use Apache Camel with Grails and found the Grails Routing plugin annd cannot even get it to install.
The directions say to install by issuing a grails install-plugin routing. When I do this I get:
grails install-plugin routing
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
.
|Environment set to development
......Warning
|
Since Grails 2.3, it is no longer possible to install plugins using the install-plugin command.
Plugins must be declared in the grails-app/conf/BuildConfig.groovy file.
Example:
grails.project.dependency.resolution = {
...
plugins {
compile ":routing:1.3.2"
}
}
So I modify my BuildConfig.groovy like so:
plugins {
// plugins for the build system only
build ":tomcat:7.0.54"
compile ":routing:1.3.2"
...lots of other stuff omitted for brevity
}
Then the plugin says to create routes, issue a grails create-route <RouteName>. So I do exactly that:
grails create-route OrderListener
Starting process on LT-IE-ZH/10.10.99.14
Loading Grails 2.4.2
|Configuring classpath
|Running pre-compiled script
|Script 'CreateRoute' not found, did you mean:
1) CreateFilters
2) CreatePom
3) CreateApp_
4) CreateController
5) CreateHibernateCfgXml
Please make a selection or enter Q to quit:
What is going on here?!? How do I install/use this plugin?!? Am I losing my mind, or does this plugin simply not work?
Update
I run grails clean-all, then grails refresh-dependencies then grails create-route OrderListener and I get:
Loading Grails 2.4.2
.
|Environment set to development
.....Error
|
groovy.lang.MissingMethodException: No signature of method: CreateRoute.createArtifact() is applicable for argument types: () values: []
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Error |
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Error |
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
Error |
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Error |
<huge stacktrace omitted>
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
Error |
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
Error |
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
Error |
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
Error |
... 68 more
Whenever you make a change in BuildConfig.groovy be sure to run grails compile to trigger dependency resolution, which will download new and updated plugins and jars, and it will also compile your code which helps to ensure that things are minimally compatible at least.
But the core issue here is that the plugin's CreateRoute.groovy script is badly broken. It's missing an important include and doesn't come close to calling createArtifact correctly. As a workaround until the authors get this fixed, create a script in your app's scripts folder called CreateCamelRoute.groovy with this content:
includeTargets << grailsScript('_GrailsCreateArtifacts')
target(createCamelRoute: "Creates a new Camel Route.") {
createArtifact(type: 'Route', path: 'grails-app/routes', name: argsMap.params?.get(0) ?: 'Example', suffix: 'Route')
}
setDefaultTarget(createCamelRoute)
It's intentionally named differently from the original because if Grails finds two with the same name it asks which one to use. This way you can just run
grails create-camel-route com.foo.bar.OrderListener
and it will work. Note that I changed the example a bit to include a package - always use packages :)

Grails error installing plugin rest-client-builder 1.0.2, bad module descriptor

Using Grails 2.0.4, I'm trying to install rest-client-builder:1.0.2 using this...
grails install-plugin rest-client-builder
...but Grails returns the error below; I've tried cleaning, refreshing dependencies, etc., keep getting the same error...
:: #rest-client-builder;1.0.2: java.text.ParseException: inconsistent module descriptor file found in 'http://plugins.grails.org/grails-rest-client-builder/tags/RELEASE_1_0_2/rest-client-builder-1.0.2.pom': bad organisation: expected='' found='org.grails.plugins';
Also tried linking the plugin as a dependency from BuildConfig.groovy, but I get a similar error...
compile (":rest-client-builder:1.0.2"){ export = false}
grailsCentral: bad organisation found in http://plugins.grails.org/grails-rest-client-builder/tags/RELEASE_1_0_2/rest-client-builder-1.0.2.pom: expected='' found='org.grails.plugins'
Looks like you put it in the dependencies section but it should be in the plugins section:
plugins {
compile(':rest-client-builder:1.0.2') {
export = false
}
}
You should remove the plugins that are still in application.properties that the install-plugin script adds and only have them in BuildConfig.groovy.

grails ui plugin not working with grails 2.1.0

I wanted to test some of the features like expandablePannels etc before putting into another project, so I created a new project with a CRUD just so I can use grails ui
I am using Intellij 11, so I installed the plugin and was responded with the following error:
Error Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.grails.plugins:yui:[2.6.0,)
IDEA hook: Grails not found!
| Error java.lang.NullPointerException
| Error at org.jetbrains.groovy.grails.rt.Agent$2.run(Agent.java:99)
| Error at java.lang.Thread.run(Thread.java:680)
Anyone else having issues using this plugin ?
Yet easier:
Edit BuildConfig.groovy and change the lines of the plugin dependency by these:
compile ":yui:2.8.2.1"
compile (":grails-ui:1.2.3") {
excludes 'yui'
}
Just in case it's useful to you.
I ran into same problem while upgrading my app from grails 1.3.7 to 2.1.0. yui is a dependency for grails-ui plugin (as grails-ui needs bubbling, and bubbling needs yui :-/) This is what I did :
Goto .grails/ivy-cache/org.grails.plugin/grails-ui folder
Open the file ivy-(version).xml (ivy-1.2.3.xml)
Look for this line : <dependency org="org.grails.plugins" name="yui" rev="**[2.6.0,)**" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)">
Replace [2.6.0,) with 2.8.2, so final line will look like this : <dependency org="org.grails.plugins" name="yui" rev="2.8.2" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)">
grails clean and grails compile
After this, this error was gone for good.
Hope this helps.
UPDATE :
Thanks to predicador37 ; Much cleaner & groovy-way of doing this - Put this under plugins in BuildConfig.groovy :
compile ":yui:2.8.2.1"
compile (":grails-ui:1.2.3") {
excludes 'yui'
}

Resources