I have read how to simply import a groovy file in another groovy script
I want to define common functions in one groovy file and call those functions from other groo
I think that the best choice is to organize utility things in form of groovy classes, add them to classpath and let main script refer to them via import keyword.
Example:
scripts/DbUtils.groovy
class DbUtils{
def save(something){...}
}
scripts/script1.groovy:
import DbUtils
def dbUtils = new DbUtils()
def something = 'foobar'
dbUtils.save(something)
running script:
cd scripts
groovy -cp . script1.groovy