In https://github.com/deephaven/deephaven-core/issues/4160, the groovy closure source() or sourceOnce() may be used to include another .groovy file as if its contents were pasted into the console. There are also other tools to manage imports in the console, such as GroovyDeephavenSession.addScriptImportClass() and addScriptImportClass(). These function by adding import lines that are used to prefix every other command that is run in the console.
We might consider a different way of making it easier to add or otherwise manage common imports in bulk, as a standard feature of the console experience, since we track those imports as state between commands.
In https://github.com/deephaven/deephaven-core/issues/4160, the groovy closure
source()
orsourceOnce()
may be used to include another .groovy file as if its contents were pasted into the console. There are also other tools to manage imports in the console, such as GroovyDeephavenSession.addScriptImportClass() and addScriptImportClass(). These function by adding import lines that are used to prefix every other command that is run in the console.We might consider a different way of making it easier to add or otherwise manage common imports in bulk, as a standard feature of the console experience, since we track those imports as state between commands.
While considering this, it might be worth looking at the groovysh project, especially import management, and see if there are other cues we could take from them on how to consistently manage imports so as to match other expectations a groovy developer might have. https://github.com/apache/groovy/blob/632d14f37e24c4e21265b53a761667e43414b54b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy#L82-L136 Basic behavior is roughly the same, but imports are removed when re-added to avoid duplicates.