[英]How to run a local plugin in Grails 2.0?
In Grails, there is a variant how to include local plugin from sources. 在Grails中,有一个变体如何从源代码中包含本地插件。 According to docs, one may type in
BuildConfig.groovy
: 根据文档,可以输入
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. 问题是它在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
. 我已经尝试过
grails clean
,用grails install-plugin
并将它放到BuildConfig.groovy
。 Still unable to resolve. 仍然无法解决。
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). 其中
shiro
是插件的名称(不是它所在目录的名称)。 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. 我发现如果插件在
application.properties
或BuildConfig.groovy
列出,这有时不起作用,所以如果是,删除它,然后执行grails clean
并重新启动应用程序。
You can also install the plugin into your local maven cache. 您还可以将插件安装到本地maven缓存中。
The documentation speaks about this: 文档说明了这一点:
3.7.10 Deploying to a Maven Repository 3.7.10部署到Maven资源库
maven-install
The maven-install command will install the Grails project or plugin artifact into your local Maven cache: maven-install命令会将Grails项目或插件工件安装到本地Maven缓存中:
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 这样做的好处是允许您使用更常见的
":plugin-name:version"
语法将插件包含在父应用程序中
Which allows your application to determine the best place to retrieve the plugin when in production. 这允许您的应用程序确定在生产中检索插件的最佳位置。 From an internal maven-repo or equivalent.
来自内部maven-repo或同等产品。
With Grails 3.x there is another way to do this. 使用Grails 3.x还有另一种方法可以做到这一点。 Suppose you've a grails app and plugin (source code) inside the same project directory:
假设您在同一个项目目录中有一个grails应用程序和插件(源代码):
/my-project
---/my-app
---/grails-shiro
To run your local plugin, you must create a settings.gradle
file in the my-project
directory specifying the location of your application and plugin: 要运行本地插件,必须在
my-project
目录中创建一个settings.gradle
文件,指定应用程序和插件的位置:
include 'my-app', 'grails-shiro'
Then add the dependency in your application's build.gradle: 然后在应用程序的build.gradle中添加依赖项:
compile project(':grails-shiro')
You've done. 你做完了
Look at the plugins documentation for more information. 查看插件文档以获取更多信息。
如果插件名称包含短划线,请使用引号括起插件名称:
grails.plugin.location.'plugin-name-with-dashes' = "<path>"
You can add the .zip file for the plugin in your /lib and it will be installed. 您可以在/ lib中为插件添加.zip文件,它将被安装。
Example: 例:
compile ":myPlugin:1.0"
File: 文件:
/lib/myPlugin-1.0.zip
Note: You have to zip the content of the plugin folder. 注意:您必须压缩插件文件夹的内容。
Source: http://grails.1312388.n4.nabble.com/Insert-own-local-plugin-into-build-config-td4646704.html 资料来源: http : //grails.1312388.n4.nabble.com/Insert-own-local-plugin-into-build-config-td4646704.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.