Scriptrunner dev environment error

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

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

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

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

Hey, @Felix Huschka. 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.

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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Apr 19, 2018 in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

366 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you