简体   繁体   English

向grails 3项目添加就地插件

[英]Adding in-place plugin to grails 3 project

In grails 2.x, we were allowed to add an in place plugin by adding following in BuildConfig.groovy 在grails 2.x中,我们被允许通过在BuildConfig.groovy中添加以下内容来添加一个就地插件

grails.plugin.location."my-plugin" = "../my-plugin" grails.plugin.location。“my-plugin”=“../ my-plugin”

My question is, can we add our local plugins similarly in-place in grails3.0 as well or there is some other way to do this in grails. 我的问题是,我们是否可以在grails3.0中同样添加我们的本地插件,或者还有其他一些方法可以在grails中执行此操作。

Actual purpose is to test the plugin whether it's working properly or not before pushing it to bintray. 实际目的是在将插件推送到bintray之前测试插件是否正常工作。

Yes, there is. 就在这里。 Grails 3 is based on Gradle so multi-project gradle builds solve your issue. Grails 3基于Gradle,因此多项目gradle构建可以解决您的问题。

Basically you add dependency as: compile project(':../my-custom-plugin') and has to modify settings.gradle to include plugin: include '../my-custom-plugin' 基本上你添加依赖为: compile project(':../my-custom-plugin')并且必须修改settings.gradle以包含plugin: include '../my-custom-plugin' compile project(':../my-custom-plugin') include '../my-custom-plugin'

Check Grails documentation on Plugins and Multi-Project Builds in http://grails.github.io/grails-doc/latest/guide/plugins.html http://grails.github.io/grails-doc/latest/guide/plugins.html上查看有关Plugins and Multi-Project Builds Grails文档

Other way is to install plugin in local maven repository using gradle publishToMavenLocal command and resolve if from there, before publishing to Bintray or other dependency repository. 其他方法是使用gradle publishToMavenLocal命令在本地maven存储库中安装插件,并在发布到Bintray或其他依赖存储库之前从那里解析。

Additionally since Grails 3.1.1, reloading is now supported for 'inline' plugins. 此外,自Grails 3.1.1以来,“内联”插件现在支持重新加载。 Check https://github.com/grails/grails-core/releases/tag/v3.1.1 and http://grails.io/post/138665751278/grails-3-gradle-multi-project-builds 检查https://github.com/grails/grails-core/releases/tag/v3.1.1http://grails.io/post/138665751278/grails-3-gradle-multi-project-builds

It is done using grails { plugins { syntax. 它是使用grails { plugins { syntax。 Copied from docs: 从文档复制:

grails {
    plugins {
        compile ":hibernate"
        compile project(':myplugin')
    }
}

This multi-project thing is a bit too big to answer in a short post. 这个多项目的事情有点太大了,无法在短篇文章中回答。 I just recently started with it, but, thankfully, I now have the hang of it. 我刚刚开始使用它,但是,谢天谢地,我现在已经掌握了它。 There's a tutorial on my site with a plugin handling the domain classes and services and all other sub-projects (just one, a web application in this example) using the plugin. 我的网站上有一个教程,其中插件使用插件处理域类和服务以及所有其他子项目(本例中只有一个,一个Web应用程序)。 The code is also downloadable. 代码也可以下载。 Here's the link: http://www.databaseapplications.com.au/grails-multi-app.jsp Make no mistake, there are a few things to watch out for. 这是链接: http: //www.databaseapplications.com.au/grails-multi-app.jsp毫无疑问,有一些事情需要注意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM