4

这个问题是我在这里发布的另一个问题的扩展:

在 Grails 2 中,如何从应用程序所依赖的插件中包含 Gant 脚本中的目标?

我正在编写一个 grails 插件,它是我公司特定版本的 shiro 插件,例如。我的公司四郎。我在 BuildConfig.groovy 中将 shiro 设置为我的插件的依赖项,如下所示:

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

我打包插件并尝试将其安装到一个名为 foo 的新 grails 应用程序中:

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

没问题。现在,我想在 foo 中运行一个脚本,它是 my-company-shiro 的一部分,它又引用了来自 shiro 插件的脚本:

foo>grails create-auth-controller

我得到以下失败:

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

这发生在 b/c 我正在执行的脚本之一尝试访问 shiro 的脚本之一,如下所示:

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

这个参考在我编译我的插件时有效,但当我在另一个 grails 应用程序中安装它时不在这里。

我是否在 BuildConfig.groovy 中错误地设置了依赖项,以至于 shiro 的文件没有包含在我的插件中,因此我无法引用它?

  • shiro 插件出现在我的 .grails 缓存 my-compnay-shiro/plugins/shiro-1.1.4
  • 当我将 my-company-shiro 插件安装到 foo 时,在 .grails 缓存 foo/plugins/my-company-shiro-0.1/dependencies.groovy 和 plugin.xml 文件中引用 shiro。我在这里没有看到任何 shiro 的脚本或文件,但我不知道它们是否应该被复制到这里。

安装时对 shiroPlugin 的引用是否不正确?

提前致谢!

4

1 回答 1

2

grails install-plugin已弃用,您需要改为使用BuildConfig.groovy。我在这里进行了测试,在应用程序中声明了自定义插件并且它可以工作,您可以使用它grails.plugin.location来指定插件的文件夹。

考虑一个名为shiro-test的插件,BuildConfig 应该是:

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"

然后你刷新你的依赖并可以从shiro-test.

于 2013-04-23T00:25:23.307 回答