As part of our process, we deploy the BPMN and associated groovy scripts using DeploymentBuilder and RepositoryService. We do this by exposing a REST endpoint. The groovy can be accessed by adding the namespace “deployment://”.
Now we want to allow users which have large complex BPMNs with many groovy scripts, to make use of common code, so that they don’t have to duplicate methods in groovy scripts. But the way we have allowed deployment, the groovy scripts cannot access methods in other files which part of that deployment.
To test, I added the common groovy code as part of our resources and deployed the BPMN with groovy scripts and these scripts could access the common files.
Is there a way to deploy groovy files and have them access each other at run time?
You could deploy your groovy packages as part of the libs folder in your application, so then you can use import to import the packages into the scripts.
side note that Nashorn (javascript) works much better for scripting in the scenario you have mentioned. You can easily use scripts and load additionals using load() function in nashorn.
This code allows you to access a deployment resource and get the resource as a String. You would then send the String into whatever “thing” in groovy would be executing the extra code.