Including a groovy script in another groovy

前端 未结 12 1522
走了就别回头了
走了就别回头了 2020-11-27 12:07

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

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 12:48

    For late-comers, it appears that groovy now support the :load file-path command which simply redirects input from the given file, so it is now trivial to include library scripts.

    It works as input to the groovysh & as a line in a loaded file:
    groovy:000> :load file1.groovy

    file1.groovy can contain:
    :load path/to/another/file invoke_fn_from_file();

提交回复
热议问题