How to import com.atlassian.jira...

Alexander January 25, 2015

I'm trying to create a custom groovy listener.
First of all, I created groovy class:

package com.custom

import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
 
class MyListener extends AbstractIssueEventListener {
    
    void issueUpdated(IssueEvent event) {
        // code
    }
}

And now, I'm trying to compile it with groovyc. I got these errors:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

MyListener.groovy: 3: unable to resolve class com.atlassian.jira.event.issu

e.AbstractIssueEventListener

 @ line 3, column 1.

   import com.atlassian.jira.event.issue.AbstractIssueEventListener

   ^

MyListener.groovy: 4: unable to resolve class com.atlassian.jira.event.issu

e.IssueEvent

 @ line 4, column 1.

   import com.atlassian.jira.event.issue.IssueEvent


How can I make it work?

1 answer

1 accepted

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2015

You'll need to set a massive classpath, but you should not need to compile it. Just point the "custom listener" at the .groovy file, and it will handle compiling.

Alexander January 26, 2015

thank you Jamie for a quick answer. But how can I point the custom listener at the groovy file if in jira, as I see, I need .class file? Or what I did wrong to make a custom listener? I put .groovy file ...WEB-INF/classes/com/custom/MyListener.groovy. And inscript runner in creating a custom listener in field: name of groovy class I cannot find it. And in jira administration where listeners, I cannot find it too.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2015

What version of jira and the plugin are you using?

Alexander January 26, 2015

jira 6.3.8, script runner plugin 3.0.7.

Alexander January 26, 2015

I created empty file hello.class in /WEB-INF/classes/com/custom/ and then I can see him as a listener, so how can I compile my first MyListener.groovy in MyListener.class? I tried groovyc and nothing good, as you see. Set a massive classpath isn't good solution. Now, I'm trying to do it with Intellij, but I met a problem: idea doesn't understand imports with com.atlassian.jira. ... And I dont know how to add it. Can you help me please, Jamie?

Alexander January 26, 2015

but you said I dont need to compile .groovy, what should I do to make it visible in "groovy class name" field?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2015

Use Custom Listener, and you put the .groovy file under one of your script roots, eg <jira_home>/scripts, in the correct directory according to its package.

Suggest an answer

Log in or Sign up to answer