Search code examples
grailsgrails-plugin

How to install Grails plugin from source code?


I got a source code of the plugin from a friend, but 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?


Solution

  • 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.