1
votes

Created a plugin in eclipse GGTS using Grails 2.3.8; standard plugin, no changes whatsoever, except for the following dependency (rabbitmq):

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

Plugin dependencies were refreshed, compiled, and packaged, then stored in local maven repo as 'myplugin:mq:0.1', and verified.

Created Grails project, added plugin to project:

//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"     
}

Dependencies refreshed successfully.

Problem

I can't reference rabbitmq libraries or dependencies from the rabbitmq plugin from myplugin:mq

Not sure why the dependencies are not being inherited by the application, I'm not using exported = false or anything to suppress the plugins dependencies.

Tried

Instead of eclipse, I switched to command line (JDK 1.7 + 2.3.8, also tried 2.3.7), manually cleaned, refreshed, compiled, and still I can't resolve rabbitmq classes:

| 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 Local Deploy

I've altered group and artifact id:

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

Plugin Package Weirdness

After closer inspection of the packaged plugin, the ZIP contains just these files. I suspect this is the problem since the rabbitmq libraries are missing and, the plugin.xml or plugin descriptor contain no references to rabbitmq dependencies, so the application is not even aware of those dependencies. But why is the plugin not including its own dependencies?

enter image description here

Plugin Descriptor

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 -> }
}
1
Did you find out whether the problem is eclipse centric or app centric. Try to compile the app out side GGTS and see whether it complains about rabbitmq dependencies not being found. - dmahapatro
By default the groupId of a plugin is org.grails.plugin. Have you modified the groupId for your plugin? compile "myplugin:mq:0.1". Can you also add the plugin descriptor to the question? - dmahapatro
question updated; I tried changing groupId and artifactId in the descriptor, did not seem to affect plugin output file, but I'm using maven to deploy to local repo (see above) to force myplugin:mq - raffian
Have you tried using grails maven-install command from the release plugin instead? - dmahapatro
The plugin zip wouldn't include binaries, but also doesn't include the dependency information either. That's stored in the .pom file. As I was typing this @dmahaptatro suggested what I was going to - use maven-install, and in the app use compile ":test-plugin:0.5" - Burt Beckwith

1 Answers

1
votes

To publish a Grails plugin to local maven repo, use the command:

grails maven-install

from release plugin which is available to all newly created Grails plugin by default.

Finally, here is how you can modify groupId of the plugin if required.