开发者

How to install Grails plugin from source code?

I got a source code of the plugin from a friend, but开发者_JS百科 still don't know how to install it into my project. Yes, there's install-plugin command, but this plugin isn't allowed to upload to the root grails plugin directory.

How can I install grails plugin from the source code?

UPDATE: the plugin is developed for Grails 1.1, but my current project is Grails 1.3. Can it cause any problem?


You can package the plugin into a zip, and install from that.

Open a command prompt in the root directory containing the plugin source and run grails package-plugin with GRAILS_HOME set to a 1.1 Grails installation and $GRAILS_HOME/bin in your PATH. This will create a zip file, e.g. grails-myplugin-0.1.zip. To install it, run grails install-plugin /path/to/grails-myplugin-0.1.zip in the containing application (using 1.3).

You will probably not have any issues installing a 1.1 plugin in a 1.3 application, but you might want to upgrade if there are issues, or to take advantage of the features of the more recent versions of Groovy and Grails.

My process for upgrading plugins or applications with a large gap in versions like this is to not run grails upgrade - that's best for smaller version deltas, e.g. to upgrade from 1.3.1 to 1.3.5.

Instead what I suggest is to create a new empty plugin in 1.1. Either manually or using a directory-diff tool, find all of the deleted, added, and modified files in the plugin by diffing the current plugin with the empty one. Then create a new empty plugin using Grails 1.3.x. Move over the new files, delete the deleted files, and make the corresponding changes in the edited files.

The edited files will mostly be under grails-app/conf, so you need to be a little careful there since some things have changed. But in general it should be safe to apply most or all of the changes.


Burt's answer is good, but another option is to simply copy all of the plugin files into a subdirectory of your project and check these in. You can then point your application to this plugin directory in BuildConfig.groovy:

grails.plugin.location.myplugin = 'myplugindir'

This way you won't have to bother with installing the plugin again in case you are building on another machine or if you clean your .grails folder.

This method is also useful in the case where you want to fork a public plugin with your own custom changes (perhaps for a local bug fix).


Since Grails 2.3, it is no longer possible to install plugins directly from the file sytem.

that it means : No Longer possible to use grails install-plugin cmd .

Instead , you should use maven as following :

  cd /to/path/root/of/myPlugin/ 
  grails maven-install 

Go now to :

   $HOME/.m2/repository/org/grails/plugins/

You will find a dir with the same name of your plugin :

   $HOME/.m2/repository/org/grails/plugins/myPlugin

IT means Plugin publishing as maven repository has been performed successfully .

THus , go to BuildConfig of your main application and add in plugins closure:

compile ":myPlugin:0.1"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜