4

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

In Grails 2, how do you includeTargets from Gant scripts from a plugin your app is dependent upon?

I am writing a grails plugin that is a my-company specific version of the shiro plugin, ex. my-company-shiro. I set shiro as a dependency for my plugin in the BuildConfig.groovy like so:

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

I package the plugin and try to install it to a new grails app called foo:

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

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

foo>grails create-auth-controller

I get the following failure:

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

This occurrs b/c one of my scripts being executed tries to access one of shiro's scripts like so:

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

This reference works when I compile my plugin, but not here when I am installing it in another grails app.

Am I setting the dependency incorrectly in the BuildConfig.groovy such that shiro's files are not being included in my plugin therefor I cannot reference it?

  • The shiro plugin shows up in my .grails cache my-compnay-shiro/plugins/shiro-1.1.4
  • When I install my-company-shiro plugin to foo, in the .grails cache foo/plugins/my-company-shiro-0.1/dependencies.groovy and plugin.xml files reference shiro. I do not see any of shiro's scripts or files here, but I have no idea if they are supposed to be copied here.

Is the reference to shiroPlugin incorrect at install time?

Thanks in advance!

Community
  • 1
  • 1
  • But the error says that there is no such property: shiroPluginDir. I am confused :S – uchamp Mar 08 '13 at 13:08
  • The shiroPluginDir property is visible when I package my plugin b/c I have shiro set as a plugin dependency. When I install my plugin to a project, I am assuming that the shiro plugin gets installed as well and this property would be visible by default (ala the answer to referenced question). – Michael Chizmar Mar 08 '13 at 16:34
  • As a note, when I list-plugins on the app I installed my plugin on, my-company-shiro is listed, but shiro is not. So, if shiro is not installed, I probably will not be able to reference the default PluginDir. So how can I access the shiro scripts at this time? – Michael Chizmar Mar 08 '13 at 16:53
  • Please post your script that have this problem. –  Apr 16 '13 at 20:56

1 Answers1

2

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

Considering a plugin named shiro-test, the 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 refresh your dependencies and can run any script from shiro-test.

  • Yeah, this worked. Seems obvious now, I just did not figure that a compile cycle was needed when updating the BuildConfig.groovy. – Michael Chizmar Jun 26 '13 at 14:05