I’m starting to add some Groovy classes to an existing Java web app. (This is not a Grails app)
Is there a convention I should follow as to where I define my metaClass extensions?
Also, I’ve written a handful of extensions for assisting with unit tests. Currently, these sit in the @Before of the base class for the tests, but I suspect there’s a more obvious place I should be setting these up.
Any advice greatly appreciated.
Another option is to use Groovy’s naming convention for custom MetaClasses. As long as you stick to the convention (
groovy.runtime.metaclass.[package].[class]MetaClass) and you compile the code with your application code you should be fine. Check this posting for more information. It also provides a good example.