Convert grails application to plugin

I started the grails application from grails create-app. For modularity, I feel that it would be better for the component to be a plugin. Can I convert this app to a Grails plugin? thanks, Baba.

+7
plugins grails
source share
2 answers

I have never created a plugin based on an application written earlier, but looking at the documentation for grails plugins , you can read the following expression:

The structure of the Grails plugin is exactly the same as the regular directory structure of the Grails project, except that in the root of the plugins directory you will find the Groovy plugin file called the “plugin descriptor”.

Therefore, I would suggest creating a new plugin with grails create-plugin *your-plugin-name* and copy all the files from your application to the plugin.

+5
source share

In case anyone is looking, this should be exactly what you need: http://burtbeckwith.com/blog/?p=1973

Excerpts:

So, to convert an application into a plugin, the overall workflow is to be something like

  • Create a handle to the FooGrailsPlugin.groovy plugin. The easiest way to do this is to run the plug-in-plugin and copy the created file from there

  • remove everything from application.properties except the app.grails.version property

  • If you have jars in the lib directory that are available in the Maven repository, delete them and replace them using BuildConfig.groovy dependencies

  • change any dependencies of the plugin and jar necessary for development and testing, but not when the plugin is installed so as not to be exported by adding export = false

  • If you need the _Install.groovy, _Uninstall.groovy or _Upgrade.groovy scripts (you probably aren't), take them from the dummy plugin from step 1 (but remove everything you don't need, theyre all optional)

  • remove ApplicationResources.groovy if you use it and not depend on the resource plugin

  • move code from BootStrap.groovy init () toFooGrailsPlugin.doWithApplicationContext and / or FooGrailsPlugin.doWithDynamicMethods and destroy () for FooGrailsPlugin.onShutdown and remove BootStrap.groovy

  • add dependency for release plugin in BuildConfig.groovy

  • delete everything except the log4j configuration from Config.groovy

  • remove UrlMappings.groovy if you did not export the mappings; save only added

  • move bean definitions from .groovy resources to FooGrailsPlugin.doWithSpring and delete resources.groovy

  • delete grails-app / i18n message files if you have not added messages; save only added

  • remove everything from grails-app / views that you are not using (specifically error.gsp, index.gsp and layouts / main.gsp)

  • remove everything from a web application that you are not using (including WEB-INF xml and tld files)

  • now is the time to write the tests you had in mind to get to

  • create one or more test applications for installing the plugin to make sure that it works as a plugin; view scripts of this

  • write documentation on how to use the plugin; at least a README file, but gils Grails files will be much better (run grails doc - for starters)

0
source share

All Articles