Groovy source in an external file

1
+1
-1

Hi,

is it possible to store the source of Groovy Script ( used in Operations or Connector ) in an external file and the simply including with a reference , so that I can mantain a single file for function called in different task/process ?

Thanks

Alberto

1 answer

1
+1
-1

Hi,

Yes, you have several ways of achieving that. You can create a Groovy script file (or multiple) in your Bonita project (Development > Groovy > New... > Create your class). Write all your business logic in them and then reference them in groovy script expressions of your processes. Either by instantiating your script instance (new MyClass().myBusinessLogic()) or use static methods in your script. The script files will be added as process dependencies in the configuration.

You can also create this logic in a custom project (using whatever tools suits you, maven, gradle, groovy, java...) and import the resulting jar file in project dependencies (the project should depend on bonita-common artifact with a provided scope to use Bonita APIs). Then use the logic in the process script expressions the same way as the first solution. This option can be trickier to implement but can give you better control as you can more easily plug unit tests on your logic.

HTH

Romain

Notifications