Creating and installing a grails plugin - how do my plugins access resources from a plugin that depends on it during / after installation?

This question is an extension from another question I wrote here:

In Grails 2, how do you include Targets from Gant scripts from the plugin your application depends on?

I am writing a Grails plugin, which is my version of siro plugins, for example. my company is shiro. I installed syro as a dependency for my plugin in BuildConfig.groovy like this:

plugins {compile(":shiro:1.1.4")} 

I will pack the plugin and try to install it in a new grails application called foo:

 foo> grails install-plugin ../my-company-shiro/grails-my-company-shiro-01.zip 

No problems. Now I want to run the script in foo, which is part of my-shiro company, which in turn references the script from the siro plugin:

 foo>grails create-auth-controller 

I get the following crash:

 Error Error executing script CreateAuthController: No such property: shiroPluginDir for class: ..... 

This is because one of my executable scripts is trying to access one of these scripts:

 includeTargets << new File (shiroPluginDir, "/scripts/_ShiroInternal.groovy") 

This link works when I compile my plugin, but not here when I install it in another grails application.

I am installing the dependency incorrectly in BuildConfig.groovy, so siro files are not included in my plugin, so I can not reference it?

  • A wide plugin appears in my .grails cache my-compnay-shiro / plugins / shiro-1.1.4
  • When I install the my-company-shiro plugin for foo, in the .grails cache foo / plugins / my-company-shiro-0.1 / dependencies.groovy and the plugin.xml files refer to siro. I do not see a single script or files here, but I have no idea if they should be copied here.

Is the shiroPlugin link incorrect during installation?

Thanks in advance!

+4
source share
1 answer

grails install-plugin deprecated, you need to use BuildConfig.groovy . I tested here by declaring a custom plugin inside the application and it works, you can use grails.plugin.location to specify the folder of your plugin.

Given a plugin named shiro-test , BuildConfig should be:

 grails.project.dependency.resolution = { ... legacyResolve true // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility ... } grails.plugin.location."shiro-test" = "path/to/plugin" 

Then you update your dependencies and can run any script from shiro-test .

+2
source

All Articles