Scriptrunner dev environment error

Michael Schlueter
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.
October 12, 2017

I have configured a dev environment as described here: https://scriptrunner.adaptavist.com/5.1.8/jira/DevEnvironment.html

Everything works fine, except that if i place the sample groovy script "UsersCount.groovy" in the "<module>/src/main/resources" folder the atlas-debug command fails with an error:

[INFO] Generating a manifest for this plugin
[INFO] using maven-bundle-plugin v2.5.3
[WARNING] Manifest com.onresolve.scriptrunner.assets:sr-sample-plugin-jira:atlassian-plugin:1.0.4-SNAPSHOT : Unused Import-Package instructions: [org.springframework.osgi.*, org.eclipse.gemini.blueprint.*]
[ERROR] Manifest com.onresolve.scriptrunner.assets:sr-sample-plugin-jira:atlassian-plugin:1.0.4-SNAPSHOT : The default package '.' is not permitted by the Import-Package syntax.
This can be caused by compile errors in Eclipse because Eclipse creates
valid class files regardless of compile errors.
The following package(s) import from the default package null
[ERROR] Error(s) found in manifest configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.198 s
[INFO] Finished at: 2017-10-12T22:17:45+01:00
[INFO] Final Memory: 60M/439M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.atlassian.maven.plugins:maven-jira-plugin:6.2.8:generate-manifest (default-generate-manifest) on project sr-sample-plugin-jira: Unable to execute mojo: Error(s) found in manifest configuration -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Content of the UsersCount.groovy:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager

def userManager = ComponentAccessor.getUserManager() as UserManager
def usersCount = userManager.getAllUsers().size()

return "My instance contains " + usersCount + " users"

Where should I place the script file instead? Is there another way to avoid this error?

2 answers

0 votes
Felix November 14, 2017

Hey @Jonny Carter, are there any updates? I run into the same issue and it seems like the workaround provided by @Michael Schlueter isn't working. Also, I'm not able to access the bug ticket - can you assist? 

 

@Michael Schlueter could you let me know how the structure of the folders looks like? So which folders you got in src and in ressources

Jonny Carter
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.
November 14, 2017

Hey, @Felix. My bad on that issue--I linked to it, forgetting it wasn't public; I've updated my comment. That said, work on the instructions for setting up a development environment is underway and improvements should be in a future release (probably not the next one, but hopefully the one after).

I can probably help with the file structure bit as well.

Basically, for the package declaration to work, your folder structure has to match. So, if your file is named Something.groovy and the package is "com.my.package", then the path to the file should be

<your script root here>/com/my/package/Something.groovy.

Michael Schlueter
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.
November 15, 2017

Yes, that's exactly the file structure that I use. It works very well for me. Writing scripts is much easier now.

0 votes
Jonny Carter
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.
October 15, 2017

I was able to reproduce this problem. I've filed a bug report, which we'll review as a dev team.

Michael Schlueter
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.
October 18, 2017

Hi Jonny,

thank you for the answer; I will watch the bug report.

I've found out that it will work without a problem if I put the sample file in a package "com.example" and create the corresponding subfolder "com/example" in the resources folder. 

Regards

Michael

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events