1
0
-1

I need to access Greenhopper classes from Groovy Runner.

I get:

Problem loading class: startup failed: /jira-plugins/ProductComponentSync.groovy: 17: unable to resolve class com.atlassian.greenhopper.model.issue.VersionWrapper @ line 17, column 1. import com.atlassian.greenhopper.model.issue.VersionWrapper ^ 1 error

The Reference link: http://docs.atlassian.com/greenhopper/6.0.7/com/atlassian/greenhopper/model/issue/VersionWrapper.html

    CommentAdd your comment...

    3 answers

    1.  
      2
      1
      0

      Here is the correct link to code which solved my problem in custom event listener in Groovy Script Runner:

      How to get Greenhopper Start and End date for Version object

        CommentAdd your comment...
      1.  
        3
        2
        1

        As Jamie (the author of the Script Runner plugin, thanks Jamie :)) has commented, it's not particularly easy to do this, but you can do it.

        Check out this other answers post with some sample Groovy code for getting the class from the plugin classloader, you can then instaniate the class.

        Thanks,
        Shaun

        1. alexey.paveliev

        2. alexey.paveliev

          I am not GH API savvy. I might be using wrong approach to getting GH extension to Version object.

          Here is another attempt. Still no luck though.

          Last line returns null.

        3. Jamie Echlin

          fails in what way? is GHversionService null?

          GHversionService is not a component in the plugin.xml, so not sure if you can do getOSGiComponentInstanceOfType on it.

        4. alexey.paveliev

          GHversionService is null despite getOSGiComponentInstanceOfType.

          I can add a debug log after pluginAccessor.getClassLoader().findClass("com.atlassian.greenhopper.service.issue.GHVersionService")

          to see if it was found

        5. alexey.paveliev

          this code results in [LoggerService] Could not get instance of GHversionService

        CommentAdd your comment...
      2.  
        1
        0
        -1

        There is no straightforward way. You might be better off writing a new plugin and using component-import and bundle-instructions etc etc. The plugins 2 framework doesn't really allow for the possibility of optionally importing stuff to the classpath at runtime, at least I haven't found a good way to do it.

        I recently enhanced the "copy project" function to clone the GH version hierarchy, scrum template, and other GH stuff, and elected to do it through http calls rather than the API. Seems to work fine although if you can use the public API that would be better.

        The other way that should work is to modify atlassian-plugin.xml and add the imports you need to the bundle-instructions section, but this is not ideal as it would get overwritten when I update it.

          CommentAdd your comment...