【问题标题】:Grails plugin dependencies not available in applicationGrails 插件依赖项在应用程序中不可用
【发布时间】:2014-10-31 01:08:43
【问题描述】:

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

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

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

创建 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"     
}

依赖刷新成功。

问题

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

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

试过

我改用了命令行(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 -> }
}

【问题讨论】:

  • 您是否发现问题是以 Eclipse 为中心还是以应用程序为中心。尝试在 GGTS 之外编译应用程序,看看它是否抱怨找不到 rabbitmq 依赖项。
  • 默认情况下插件的groupId是org.grails.plugin。您是否为您的插件修改了groupIdcompile "myplugin:mq:0.1"。你也可以在问题中添加插件描述符吗?
  • 问题已更新;我尝试更改描述符中的groupIdartifactId,似乎没有影响插件输出文件,但我使用maven 部署到本地repo(见上文)强制myplugin:mq
  • 您是否尝试过使用发布插件中的grails maven-install 命令?
  • 插件 zip 不包含二进制文件,但也不包含依赖信息。这存储在 .pom 文件中。当我输入这个@dmahaptatro 建议我要做什么 - 使用maven-install,并在应用程序中使用compile ":test-plugin:0.5"

标签: maven grails groovy buildconfig ggts


【解决方案1】:

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

grails maven-install

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

最后,here is how 可以根据需要修改插件的groupId

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-06
    • 1970-01-01
    • 2021-07-09
    • 1970-01-01
    • 2013-03-22
    • 2016-08-01
    • 2014-04-25
    相关资源
    最近更新 更多