How to run a local plugin in Grails 2.0?

11,632

Solution 1

This works for me

grails.plugin.location.shiro = "/home/dilbert/dev/plugins/grails-shiro"

Where shiro is the name of the plugin (not the name of the directory it's in). Make sure the path to the plugin is either an absolute path or the relative path to the plugin from the application.

I've found that this sometimes doesn't work if the plugin is listed in application.properties or BuildConfig.groovy, so if it is, remove it, then execute grails clean and restart the app.

Solution 2

You can also install the plugin into your local maven cache.

The documentation speaks about this:

3.7.10 Deploying to a Maven Repository

maven-install

The maven-install command will install the Grails project or plugin artifact into your local Maven cache:

grails maven-install

This has the advantage of allowing you to include the plugin in your parent application using the more common ":plugin-name:version" syntax

Which allows your application to determine the best place to retrieve the plugin when in production. From an internal maven-repo or equivalent.

Solution 3

With Grails 3.x there is another way to do this. Suppose you've a grails app and plugin (source code) inside the same project directory:

/my-project
---/my-app
---/grails-shiro

To run your local plugin, you must create a settings.gradle file in the my-projectdirectory specifying the location of your application and plugin:

 include 'my-app', 'grails-shiro'

Then add the dependency in your application's build.gradle:

 compile project(':grails-shiro')

You've done.

Look at the plugins documentation for more information.

Solution 4

Surround the plugin name with quotes in case it contains dashes:

grails.plugin.location.'plugin-name-with-dashes' = "<path>"
Share:
11,632

Related videos on Youtube

Dmitry Kurinskiy
Author by

Dmitry Kurinskiy

Updated on September 13, 2020

Comments

  • Dmitry Kurinskiy
    Dmitry Kurinskiy over 3 years

    In Grails, there is a variant how to include local plugin from sources. According to docs, one may type in BuildConfig.groovy:

    // Useful to test plugins you are developing.
    grails.plugin.location.shiro =
            "/home/dilbert/dev/plugins/grails-shiro"
    
    // Useful for modular applications where all plugins and
    // applications are in the same directory.
    grails.plugin.location.'grails-ui' = "../grails-grails-ui"
    

    The problem is that it doesn't work in Grails 2.0.RC1. I've tried to do grails clean, to install plugin with grails install-plugin and to place it to BuildConfig.groovy. Still unable to resolve.

    • tim_yates
      tim_yates over 12 years
      What error do you get? I just tried the BuildConfig route, with 2.0RC1 and it seems to work fine... You are doing one or the other aren't you? Not grails install-plugin AND placing it in BuildConfig.groovy at the same time?
    • Dmitry Kurinskiy
      Dmitry Kurinskiy over 12 years
      That was damn simple. With this grails.plugin.location.* line you just shouldn't install plugin at all. Just type this lint in BuildConfig.groovy and do grails run-app!
    • Dmitry Kurinskiy
      Dmitry Kurinskiy over 12 years
      I was trying to install-plugin or put it into BuildConfig DSL the same time :) thanks @tim_yates
  • Joseph
    Joseph about 10 years
    This is not effective as you would have to zip and replace the file every time an update is done. Forget this step and you'll be tracking down some really confusing problems.
  • Tyler Rafferty
    Tyler Rafferty almost 8 years
    This method works for me by adding to the buildConfig.groovy. +1 to @andruso for his comment concerning dashes. If your plugin contains a hyphen, then wrap the plugin name in quotes. Example: grails.plugin.location.'plugin-name-with-dashes' = "<path>"