How to install Grails fields plugin scaffolding templates - grails

I am using Grails 3.0.4. The fields plugin documentation states that the scaffolding templates can be installed using the command "grails install-form-fields-templates".
How ever is Grails 3.0.4 there is no install-form-field-templates command which can be used not the Grails console.
Does any one know how to install fields plugin scaffolding templates in Grails 3?

Filed an issue in Grails Fields plugin. Got a response from them that the command to use is Grails install templates. This just installs the scaffolding templates. For more info, pls browse https://github.com/grails3-plugins/fields/issues/14

It's actually grails install-templates. The hyphen is needed.

Unfortunately the command "grails install-templates" does not create the templates to be used by the fields plugin. For example: The template _wrapper.gsp (v.1.5 onwards) or _field.gsp (before v.1.5) which should be found in grails-app/views/_fields/default/_wrapper.gsp is not created. And it is up to the developer to infer how it should be structured.This is a bit inconvenient.

Related

How do I configure installation of plugins in Grails 3.0.4?

I'm porting an application from Grails 2.4.2 to Grails 3.0.4, and I'm having problems with some plugins that were installed previously. Specifically one that is referenced in a GSP page. The particular plugin is called google-visualizer, and I've found some info here:
https://github.com/bmuschko/grails-google-visualization/blob/master/grails-app/views/formatter/index.gsp
However, I am clueless as to how to install this. I have not found the particular jar file in any maven repo, so I can't add it as a Gradle dependency. In general, where is it documented how to install existing plugins in Grails 3.X? I've read the documentation on how to port existing plugins, but that's not what I'm trying to do. I simply want to tell Grails/Gradle that I'd like to use this particular plugin and have it resolve the dependencies for me. I've tried this syntax as shown here:
https://grails.org/plugins/tag/grails3
Example:
compile ":quartz:1.0.2"
I've put that line in the dependencies block in my build.gradle file, but it doesn't work. I get errors from Gradle. Is there a particular Maven repo that has to be added for plugins? Any help with this is appreciated. Thanks.
Grails 1.x and 2.x plugins are sadly not compatible with Grails 3.x.
You can find the plugins that already have been ported to Grails 3 at: https://bintray.com/grails/plugins/
The grails-google-visualization plugin is not released in a Grails 3 version, but from the repo, it appears that work has started on upgrading.
You can see the progress on a Grails 3 version in this issue: https://github.com/bmuschko/grails-google-visualization/issues/49
Benjamin searched for a new maintainer back some time ago, and found a volunteer - see this tread for details: https://twitter.com/bmuschko/status/498610606896066560
For those plugins that are most important, the Grails Core team maintains a list here: https://github.com/grails/grails-core/wiki/Grails-3-Priority-Upgrade-Plugins
Some of the old plugins will be replaced by their Gradle counterpart, fx. the codenarc plugin, that exist in a Gradle version already.
A simple way is to find out the JAR file for the plugin and then use them in Grails 3.0.4. In this way there is no need to change the source code of the plugin

Looking for integrate-with in grails 3.x

the command
grails integrate-with --foo
is gone in grails 3.x. Has that functionality not been implemented yet, or is it hiding somewhere I don't know where to find it?
As mentioned in the comments, there's no need for the IDE integration command, but an auto-generated .gitignore file is definitely nice to have and something that was missing in the early 3.x releases.
Since Grails 3.0.5, a .gitignore file is created by default with the create-app command.
See the GitHub issue: Default integration with Git on grails create-app command.

Using Grails 2.4.3 in IntelliJ

I've been unable to create/import a Grails 2.4.3 project with IntelliJ 13.1.4. For example, when I create a new module, choose Grails, then click the create button (highlighted below) and choose the location where Grails 2.4.3 is installed, the project is not created correctly (I get a module with just a /src directory instead of a Grails project) and Grails 2.4.3 is not added to the list of Global Libraries. I don't have this problem with any earlier version of Grails.
I have used Grails 2.4.2 with Intellij 13.1.4 successfully. What I did is create the application with the grails create-app command and then do a File / Import Project in Intellij. Give that a try.
As an alternative solution to the IntelliJ 13.1.4 and Grails 2.4.3 bug you can:
grails create app <app-name>
cd app-name
grails integrate-with --intellij
This configured the project correctly for me with just minor tweaks to SDK and application server. This is a minor twist on the work around described above.
See grails doc here
I had the same problem with IntelliJ 13.1.4 and Grails 2.4.3, which i just downloaded.
After using the grails create-app command from the command line i had to import the project, by "create from existing sources" (point to the new top level folder), "Configure SDK" (to set for the Grails 2.4.3) and finally edit the run configuration. In a second test run with a new test project i did not have too configure the run config.
Then the Grails libs for the were downloaded and the basic app ran. Also the Grails specific option in the Intellij "Tools2 section were suddenly available.
So the given answer by Joe is the way to setup a new Grails project but the IDE should be fixed anyways.
It is not consistent. After several tries I can get some applications to work but it does not seem to be automatic. I think I am going to go back to Grails 2.4.2 until this is resolved within Intellij 13.1.4.
In the screenshot above, there are options for groovy/grails/griffon, and so far the alternative offered was command-line. Try choosing groovy option within intelliJ.
We are using IDEA 13.1.4 with grails 1.3.7 and grails 2.2.1(diff projects) and saw the same issue. It appears this is an intelliJ issue and not so much the grails version, so reverting your grails won't gain you anything. Choosing groovy, you should see a prompt for grails directory structure. This does work if you are presented with this option. Seeing inconsistencies here. Thanks to all for posting your workarounds; never hurts to have multiple approaches.
-Duane

Were the generate-* commands removed from Grails 2.3.2?

When I type generate-all, generate-controller or generate-vies, Grails current version (2.3.2) does not recognizes them. However, these commands remains on the Grails documentation. Does anyone knows if these commands were removed (and the docs are not up-to-date)?
Try grails compile first.
These commands are now part of the scaffolding plugin, and you might need to get grails to fetch the plugin

Getting Grails version from within plugin _install.groovy script

One of my plugins needs to behave differently for grails 1.x and 2.x. So I would like to switch based on the grails version used to install the plugin, but I didn't find a way to get the grails version...
Any idea?
You can use grails.util.Metadata.current.getGrailsVersion(). Note that you cannot use the property-access variant (grails.util.Metadata.current.grailsVersion) because Metadata is a Map and this will look for the property stored under the key "grailsVersion" and return null since it's stored under "app.grails.version".
To check your grails version:
grails -version
When installing an older plugin, be sure to configure the version in
application.properties
in your grails project.

Resources