1

使用 Grails 在 eclipse GGTS 中创建了一个插件2.3.8;标准插件,没有任何变化,除了以下依赖项(rabbitmq):

//BuildConfig (plugin)
plugins {
   compile(":rabbitmq:1.0.0")
   build(":release:3.0.1",
         ":rest-client-builder:1.0.3")         
}

插件依赖被刷新、编译和打包,然后存储在本地 maven repo 中'myplugin:mq:0.1',并验证。

创建 Grails 项目,将插件添加到项目中:

//BuildConfig (project)
plugins {            
   build ":tomcat:7.0.52.1"
   compile "myplugin:mq:0.5"  //<-plugin here

   compile ":scaffolding:2.0.3"
   compile ':cache:1.1.2'

   runtime ":database-migration:1.4.0"
   runtime ":jquery:1.11.0.2"     
}

依赖关系刷新成功。

问题

我无法从 rabbitmq 插件中引用 rabbitmq 库或依赖项myplugin:mq

不知道为什么应用程序没有继承依赖项,我没有使用exported = false或任何东西来抑制插件依赖项。

试过了

我没有使用eclipse,而是切换到命令行(JDK 1.7 + 2.3.8,也尝试了2.3.7),手动清理,刷新,编译,仍然无法解析rabbitmq类:

| Error Compilation error: startup failed:
C:\X-projects\ws-ggts_36\rest-api-doc-test\grails-app\controllers\org\raffian\restapi\controller\FundController.
 @ line 8, column 1.
   import org.springframework.amqp.rabbit.core.RabbitAdmin
   ^

Maven 本地部署

我已经更改了组和工件 ID:

mvn install:install-file  
    -Dfile=grails-test-plugin-0.5.zip
    -DgroupId=myplugin
    -DartifactId=mq
    -Dversion=0.5
    -Dpackaging=zip
    -DgeneratePom=true

插件包怪异

在仔细检查打包插件后,ZIP 仅包含这些文件。我怀疑这是问题,因为 rabbitmq 库丢失了,并且 plugin.xml 或插件描述符不包含对 rabbitmq 依赖项的引用,所以应用程序甚至不知道这些依赖项。但是为什么插件不包含它自己的依赖项呢?

在此处输入图像描述

插件描述符

class TestPluginGrailsPlugin {
    // the plugin version
    def version = "0.5"
    // the version or versions of Grails the plugin is designed for
    def grailsVersion = "2.3 > *"
    // resources that are excluded from plugin packaging
    def pluginExcludes = [
        "grails-app/views/error.gsp"
    ]

    def title = "Test Plugin Plugin" // Headline display name of the plugin
    def author = "Your name"
    def authorEmail = ""
    def description = 'desc'
    def documentation = "http://grails.org/plugin/test-plugin"
    def doWithWebDescriptor = { xml ->}
    def doWithSpring = {}
    def doWithDynamicMethods = { ctx -> }
    def doWithApplicationContext = { ctx -> }
    def onChange = { event -> }
    def onConfigChange = { event -> }
    def onShutdown = { event -> }
}
4

1 回答 1

1

要将 Grails 插件发布到本地 maven 存储库,请使用以下命令:

grails maven-install

fromrelease插件,默认情况下可用于所有新创建的 Grails 插件。

最后,如果需要,您可以在此处groupId修改插件。

于 2014-10-31T14:05:18.913 回答