I think that @Grab needs to be 'attached' to something like an import.
The doco (https://groovy-lang.org/grape.html) says:
"""
Note that we are using an annotated import here, which is the recommended way.
"""
Take a look at:
https://dzone.com/articles/groovy-and-jsch-sftp
HTH
BOB
From: QuoĆ
Hello Bob!
Thanks for your answer. Yes, of course the right way would be to also
use the 'grabbed' dependency in one way or the other.
This test script of mine was for investigating what dependency in a
large script of mine pulls in groovy-all:2.4.x making this script
unusable with Groovy 4.
If you look up the Javadoc for Grab, you will see that it can be on
more things than just an import. It can be on a type, a method, a
field, a local variable and so forth. It can't be used on a single
statement. The suggestion for placing it on an import statement is
really just a suggestion. It is