Extending the functionality of the Grails plugin

I would like to know if this is possible, and if there is a general way to extend the functionality of the grails plugin.

I recently installed a plugin with comments, but you need to make some changes. Since the code is not saved with the project (but in the user directory), if I change it, after updating the plugin (or the project on some other computer), these changes are lost.

Does anyone have any ideas?

Thanks Nicolas

+7
source share
3 answers

If you want to redefine an artifact (for example, a domain class), create the same name with your project. Plugins are compiled separately from application classes, and their artifacts are registered first, so if there is an artifact in the main application, it will replace the plugin. Just remember to use the same package for domain classes, although this is not required for controllers or services.

+9
source

If you want to completely change the plugin, you can try to change and then recompile the plugin and create it in a zip file with a different name.

You can then install the customized plugin from the source code. You can refer to here.

+4
source

In one project, we needed a list of allowed email addresses that were allowed to send mail for one environment (QA), so various different parties involved in the project could test the application without the risk of any mail being sent to our clients' clients (end users) .

There was too much work to change all the code blocks that performed the distribution, so I implemented my own extender for the main class of the mail plug-in (grails.plugin.mail.MailMessageBuilder), which took the list of allowed email addresses from the application configuration and redefined the method. which resolved addresses before sending mail (toDestinationAddresses). Then I replaced the factory (plugin) method that MailMessageBuilders creates, so it created my own collectors using the Groovy metaClass in the Grails boot file.

It was a clean, non-intrusive fix, and it worked great.

0
source

All Articles