[英]How to run a local plugin in Grails 2.0?
在Grails中,有一個變體如何從源代碼中包含本地插件。 根據文檔,可以輸入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"
問題是它在Grails 2.0.RC1中不起作用。 我已經嘗試過grails clean
,用grails install-plugin
並將它放到BuildConfig.groovy
。 仍然無法解決。
這適合我
grails.plugin.location.shiro = "/home/dilbert/dev/plugins/grails-shiro"
其中shiro
是插件的名稱(不是它所在目錄的名稱)。 確保插件的路徑是絕對路徑或應用程序插件的相對路徑。
我發現如果插件在application.properties
或BuildConfig.groovy
列出,這有時不起作用,所以如果是,刪除它,然后執行grails clean
並重新啟動應用程序。
您還可以將插件安裝到本地maven緩存中。
文檔說明了這一點:
maven-install
maven-install命令會將Grails項目或插件工件安裝到本地Maven緩存中:
grails maven-install
這樣做的好處是允許您使用更常見的":plugin-name:version"
語法將插件包含在父應用程序中
這允許您的應用程序確定在生產中檢索插件的最佳位置。 來自內部maven-repo或同等產品。
使用Grails 3.x還有另一種方法可以做到這一點。 假設您在同一個項目目錄中有一個grails應用程序和插件(源代碼):
/my-project
---/my-app
---/grails-shiro
要運行本地插件,必須在my-project
目錄中創建一個settings.gradle
文件,指定應用程序和插件的位置:
include 'my-app', 'grails-shiro'
然后在應用程序的build.gradle中添加依賴項:
compile project(':grails-shiro')
你做完了
查看插件文檔以獲取更多信息。
如果插件名稱包含短划線,請使用引號括起插件名稱:
grails.plugin.location.'plugin-name-with-dashes' = "<path>"
您可以在/ lib中為插件添加.zip文件,它將被安裝。
例:
compile ":myPlugin:1.0"
文件:
/lib/myPlugin-1.0.zip
注意:您必須壓縮插件文件夾的內容。
資料來源: http : //grails.1312388.n4.nabble.com/Insert-own-local-plugin-into-build-config-td4646704.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.