What is a Grails Plugin? What does it mean to Install a Plugin?
Asked Answered
A

3

13

I used Grails recently, and added Grails plugin for JQuery, but I don't think it did anything more than just copy some jQuery files over.

So far, I have seen info only on 'how to install and use' plugins...but I can't find anything that describes the concept of a plugin.

Can somebody please tell me, what is a Grails Plugin? And what does it mean to 'Install' a plugin?

Abigael answered 23/5, 2011 at 16:46 Comment(0)
S
15

A Grails plugin is (or should be) a self-contained bundle of functionality that can be installed into a Grails application. When a Grails plugin is installed, it can do any of the following:

  • define additional Spring beans
  • modify the generated web.xml
  • add new methods to the application's artefacts (controllers, domain classes, services, etc.)
  • provide new tag libraries
  • make additional resources and classes available to the application
  • provide new Grails commands

For example, when you install the JQuery plugin

  • the JQuery JavaScript files are added to the application
  • a new Grails tag <jq:jquery> is added to the application
  • a new Grails command grails install-plugin jquery is added to the application

When you install a Grails plugin, that plugin's functionality is made available to the installing application. However, the plugin itself is not actually copied into the application, only the plugin name and version is added to the application's application.properties file. The plugin itself is downloaded to $HOME/.grails and the application loads it from there.

The structure of a Grails plugin project is identical to that of a Grails application, with the exception of a configuration file (known as a plugin descriptor) that is included in a plugin's root directory.

Socialite answered 23/5, 2011 at 16:58 Comment(2)
So we could end up introducing 'behavior' the application. I guess understanding what all things a plugins adds, can be really criticalAbigael
Don should author the grails-plugin tag wiki summary.Frankel
S
2

Well, a Grails plugin is some piece of software that extends the frameworks funcionalities in some manner. Generally, installing a plugin in Grails means copying it to your Grails folder, so projects can refer to it and Grails will know where to find it.

Grails plugins have this folder structure:

  • grails-app
    • controllers
    • domain
    • taglib
    • service
    • etc
  • lib
  • src
    • java
    • groovy
  • web-app
    • js
    • css

So anything it has there will also be available to the application that uses it. For example, the Searchable plugin has a service class which you can use to perform advanced searchs in your own domain classes .

The jQuery plugin you mentioned has the jQuery .js file, and a tag to include that file.

For information on creating plugins, see http://grails.org/doc/latest/guide/12.%20Plug-ins.html

Signal answered 23/5, 2011 at 17:1 Comment(0)
S
1

A plugin is just a set of functionality around a desired purpose. So the Spring Security plugin provides a way to lock down your app, assign roles to users, restrict access, whatever. The Searchable plugin allows you to integrate advanced searching into your app. There are lots of plugins

The point is to provide useful functionality so that you don't have to implement hard things yourself. Someone did something useful, and they wanted to contribute back to the community, so they organized their functionality and made it available.

A plugin is code and configuration, like any functionality you would implement yourself.

There is some documentation here: http://grails.org/doc/latest/ref/Plug-ins/Usage.html

Spalato answered 23/5, 2011 at 16:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.