Skip to content

Instantly share code, notes, and snippets.

@vahidhedayati
Last active July 31, 2016 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vahidhedayati/46006e815cf31134d4ff to your computer and use it in GitHub Desktop.
Save vahidhedayati/46006e815cf31134d4ff to your computer and use it in GitHub Desktop.
Grails3 plugin instructions.md

http://grails.github.io/grails-doc/3.0.x/guide/upgrading.html

Follow above instructions in order to get the content of your grails plugin from older grails into grails 3.

A few notes on plugin names and folder names, I put down a few things here: https://groups.google.com/forum/#!topic/grails-dev-discuss/cG_6mvAO3f8

In there I mentioed mvn install - which does not appear to work under normal circumstances, in order to get a plugin to work locally follow grails install instructions or do it as inline plugin ..

http://grails.github.io/grails-doc/latest/guide/plugins.html

.....

Back to plugins in grails 3 and testing locally:

I have since found that depending on what the actual folder name is that contains all the plugin files the jar files generated will be that name.

so if you have a folder called

grails-wschat-plugin and inside is the contents of wschat then the created jar and local maven file will be grails-wschat-plugin

If the name should be wschat the simplest thing would be to come one step up from folder

cd ..
ln -s grails-wschat-plugin ./wschat

then cd wschat 

and grails package-plugin

Installing Local Plugins

To make your plugin available for use in a Grails application run the install command:

grails install

This will install the plugin into your local Maven cache. Then to use the plugin within an application declare a dependency on the plugin in your build.gradle file:

compile "org.grails.plugins:quartz:0.1"

ls -l ~/.m2/repository/org/grails/plugins/wschat/1.15/
total 1.9M
-rw-rw-r-- 1 me me 1.6M Mar  6 09:39 wschat-1.15.jar
-rw-rw-r-- 1 me me 141K Mar  6 09:39 wschat-1.15-javadoc.jar
-rw-rw-r-- 1 me me 2.8K Mar  6 09:39 wschat-1.15-plugin.xml
-rw-rw-r-- 1 me me  612 Mar  6 09:39 wschat-1.15.pom
-rw-rw-r-- 1 me me  68K Mar  6 09:39 wschat-1.15-sources.jar

compile "org.grails.plugins:wschat:1.15"

Inline Plugins in Grails 3.0

In Grails 2.x it was possible to specify inline plugins in BuildConfig, in Grails 3.x this functionality has been replaced by Gradle's multi-project build feature.

To set up a multi project build create an appliation and a plugin in a parent directory:

$ grails create-app myapp
$ grails create-plugin myplugin

Then create a settings.gradle file in the parent directory specifying the location of your application and plugin:

include 'myapp', 'myplugin'

Finally add a dependency in your application's build.gradle on the plugin:

compile project(':myplugin')

1 step back i.e. root folder outside of my app folder:

[09:52 me@myhost testwschat] > cat ../settings.gradle 
include 'testwschat', 'wschat'


[09:52 me@myhost testwschat] > ls -ld ../wschat/
drwxrwxr-x 8 me me 4.0K Mar  5 15:52 ../wschat/
[09:52 me@myhost testwschat] > ls -ld ../testwschat/
drwxrwxr-x 6 me me 4.0K Mar  6 09:47 ../testwschat/
[09:52 me@myhost testwschat] > 

cat testwschat/build.gradle

dependencies {
....
 compile project(':wschat')
}

Configuration

http://grails.github.io/grails-doc/latest/guide/conf.html

If you prefer to use Grails 2.0-style Groovy configuration then you can create an additional grails-app/conf/application.groovy file to specify configuration using Groovy's ConfigSlurper syntax.

cat grails-app/conf/application.groovy

wschat.add.appName='no'
wschat.defaultperm='admin'
wschat.rooms = ['fred','smith','room3']
wschat.showtitle="no"
wschat.hostname='192.168.1.6:8080'
stunServers { iceServers=[ [url: 'stun:stun.l.google.com:19302'] ] }
//wschat.send.leftroom='no'
//wschat.send.joinroom='no'
//config.frontenduser='_frontend'
//config.storeForFrontEnd=false
wschat.dbstore=true
wschat.dbstore_pm_messages=true
wschat.dbstore_room_messages=true
wschat.debug=true

Testing actual plugin:

Message
    Request processing failed; nested exception is org.grails.gsp.GroovyPagesException: Error processing GroovyPageView: [views/wsChat/chat.gsp:17] [views/wsChat/_chat.gsp:35] [views/_banuser.gsp:40] No javascript provider is configured

more wschat/grails-app/views/_banuser.gsp

   40                 </g:formRemote>

remoteForm does not appear to exist under grails 3 as yet

There is ajax-tags plugin: (trying to figure out how to call this)

grails list-plugin

To get ajax-taglib installed :

  1. Go to https://github.com/grails3-plugins/ajax-tags/blob/master/build.gradle

Look @ Version :

under your application build.gradle add the dependency:

dependencies {
       compile 'org.grails.plugins:ajax-tags:1.0.0.BUILD-SNAPSHOT'
}

This how ever has not fixed the issue with remoteForm - so for now going to disable it to move forward....

Controllers in Grails 3 M2:

https://github.com/vahidhedayati/testads/blob/master/grails-app/controllers/ajaxdependancyselectexample/MyContinentController.groovy You will notice for each controller action I have had to define render and a view page. In short with no render definition under grails 3 returns a blank page......

TagLibs under Grails 3:

https://github.com/vahidhedayati/ajaxdependancyselection/blob/grails3/grails-app/taglib/grails/plugin/ajaxdependancyselection/AutoCompleteTagLib.groovy

class AutoCompleteTagLib {
def autoCompleteService
static namespace = "ads"
GrailsApplication grailsApplication
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment