See here scijava/scijava-jupyter-kernel#10 (comment) and here scijava/scijava-jupyter-kernel#28 for history.
We could re-use the Scijava annotation mechanism with a syntax similar to this :
// @GrabResolver name='imagej', root='http://maven.imagej.net/content/groups/public/'
// @Grab 'net.imagej:imagej:2.0.0-rc-58'
import net.imagej.ImageJ
Image ij = new ImageJ()
For the implementation, the Groovy grape module could be a good source of inspiration : https://github.com/apache/groovy/tree/master/src/main/groovy/grape