Showing results for 
Search instead for 
Did you mean: 

Use groovy script from Script Collection inside another groovy script

0 Kudos

Hi experts,

In terms of maximizing the reusability of my Groovy scripts, I am trying to use some custom functions located in CustomFunctions.groovy (which is inside my Script Collection), inside my Main.groovy (also in the same Script Collection).

I've tried to import the CustomFunctions through a GroovyShell but that resulted in a FileNotFoundException.
Any other way I can achieve this? Preferrably through an import statement (and not with a .jar)?

Any help would be much appreciated!
Thanks, Jan

GroovyShell shell = new GroovyShell()
Script script = shell.parse(new File('./CustomFunctions.groovy'))

javax.script.ScriptException: /home/vcap/app/script/CustomFunctions.groovy (/home/vcap/app/script/CustomFunctions.groovy), cause: /home/vcap/app/script/CustomFunctions.groovy (/home/vcap/app/script/CustomFunctions.groovy)
0 Kudos

the groovy script is inserted on a temporally environment when you deploy your iFlow, they scripts are on resources folder of expanded jar.

If you want to try to know where is your data, you must list directories of node and check where are they expanded.

I did, in past, a groovy script to list entire node folder/file list with java libraries.

I found ones:

Instead . you can put / and instead println it, you can add on a string and put them on a property or body.

import static

new File('.').eachFileRecurse(FILES) {
    if('.groovy')) {
        println it
0 Kudos

Good idea, but I was hoping to be able to point directly to the .groovy file in the script.
Right now the best option seems a .jar which I can import at the top, but that's a bit of a hassle if you need to update it.

Accepted Solutions (0)

Answers (0)