groovy - Reference things from imported class in groovysh -
say have somethings.groovy
file:
def somevar = 'abc' def somefunc(a) { + 1 }
i start groovysh above file on classpath , do:
groovy:000> import somethings ===> somethings groovy:000>
all good. however:
groovy:000> somevar unknown property: somevar groovy:000> somefunc(1) error groovy.lang.missingmethodexception: no signature of method: groovysh_evaluate.somefunc() applicable argument types: (java.lang.integer) values: [1] groovy:000>
how reference somevar
, somefunc
groovysh?
modify somethings.groovy
below:
//somethings.groovy somevar = 'abc' // remove def create variable available shell def somefunc(a) { + 1 }
then file has load
ed shell below (load somethings.groovy
can used instead). :h or :help show usage.
groovy:000> . somethings.groovy ===> abc ===> true groovy:000> somevar ===> abc groovy:000> somefunc(1) ===> 2 groovy:000>
groovy groovyshell
No comments:
Post a Comment