How to install Grails plugin from source code?
Asked Answered
I

3

13

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?

Interracial answered 14/12, 2010 at 3:31 Comment(0)
T
10

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.

Thilde answered 14/12, 2010 at 4:29 Comment(0)
F
10

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

Fazeli answered 17/9, 2012 at 1:9 Comment(1)
If your plugin contains a hyphen, then wrap the plugin name in quotes. Example: grails.plugin.location.'plugin-name-with-dashes' = "myplugindir"Angling
F
6

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"
Foliated answered 29/12, 2014 at 12:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.