开发者

What is a Grails Plugin? What does it mean to Install a Plugin?

开发者 https://www.devze.com 2023-03-07 16:31 出处:网络
I used Grails recently, and added Grails plugin for JQ开发者_JAVA百科uery, but I don\'t think it did anything more than just copy some jQuery files over.

I used Grails recently, and added Grails plugin for JQ开发者_JAVA百科uery, 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?


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.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号