In an attempt to structure my code better than I had it before I have decided to use classes but now I have an issue with imports .My set up looks like this
-mypackage
--ModifiedIssues.groovy (contains the class ModifiedIssuesHelper)
--ModifiedIssuesEndpoint.groovy (This will be a scriptrunner endpoint, for now it is just a script)
When I try to run ModifiedIssuesEndpoint.groovy in scriptrunner (using the console) I get the following errors:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: file:/C:/Users/tonje.stolpestad/scripts-repository/src/main/resources/mypackage/ModifiedIssuesEndpoint.groovy: 2: unable to resolve class mypackage.ModifiedIssuesHelper @ line 2, column 1. import mypackage.ModifiedIssuesHelper ^ 1 error
The files are as follows:
//ModifiedIssuesEndpoint.groovy package mypackage; import com.atlassian.jira.issue.Issue; import mypackage.ModifiedIssuesHelper //Locally private String userKey = "admin" private String jqlSearch = "issuetype in (\"Work Package\", \"Master Change\")" ModifiedIssuesHelper modifiedIssuesHelper = new ModifiedIssuesHelper(); List<Issue> issues = modifiedIssuesHelper.findIssues(userKey, jqlSearch); List<Map> filteredIssues = modifiedIssuesHelper.filterIssues(issues); log.debug filteredIssues;
//ModifiedIssues.groovyas package mypackage import ... class ModifiedIssuesHelper { public List<Issue> findIssues(String userKey, String jqlSearch){...} public List<Map> filterIssues(List<Issue> issues){...} }
Community moderators have prevented the ability to post new answers.
When you are creating the endpoint, are you putting in just:
mypackage/ModifiedIssuesEndpoint.groovy
You should... I'm guess that C:/Users/tonje.stolpestad/scripts-repository/src/main/resources is not set as a scripts root. Script Console file tab shows you the script roots. You can set it using https://scriptrunner.adaptavist.com/latest/jira/#_script_roots.
I am getting these as script roots in the console tab: Available script roots are C:/Users/tonje.stolpestad/scripts-repository/src/main/resources/, C:\Users\tonje.stolpestad\scripts-repository\atlassian-apps\jira\amps-standalone\target\jira\home\scripts
And in the path to the file I am just entering mypackage/ModifiedIssuesEndpoint.groovy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried to set up a test class for the ModifiedIssuesHelper and I got the same sort of unable to resolve error there. That suggests to me that there is either something wrong with my packages or in the helpers class structure. What do you think @Jamie Echlin [Adaptavist]?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The class ModifiedIssuesHelper should be in a file: ModifiedIssuesHelper.groovy. It looks like it's in a different name? You can have multiple top-level classes in the same file in groovy, but can you rename it to see if that's the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. I have tried changing to that. I also tried making a new class in a new file and using that but I am getting the same error then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After some googling I saw a suggestion to remove the "!?*.groovy" in the complie settings in my IDE (IntelliJ) and this gives me a different issue. Now when I run the tests it says it can't find the class for the tests. I am not sure if this is a step in the right or wrong direction
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did some more restructuring to try to fix the problem.
Now I have set up so that it is set up with
-src
--main/resources/mypackage/util/utilclass.groovy (where the class shares the name as the file)
--test/util/utilclasstest.groovy (which imports utilclass)
As mentioned above I removed the "!?*.groovy" in the compile settings. This means I can build and compile the project but when I try to run the test class I get "Class not found: "util.utilclasstest""
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm lost now, there should be no need to compile it in IDEA.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're really not getting anywhere create a ticket at https://productsupport.adaptavist.com/servicedesk/customer/portal/2 and we can do a screenshare on Monday afternoon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.