I want to start my first project in Grails and I want to split in more application/plugins.
For now I have only one site/application (/myproj/projectA). In the future I want to add a new application (/myproj/projectB) and I want to reuse some of logic of projectA (Ex. UserService).
In Grails, what is the way? Create 2 applications (projectA, projectB) and one common (ex.with UserService) plugin?
How do it?
The final result is : I want to update single application without redeploy entire application.
Thanks in advance
Creating reusable/shared functionality is one of the key advantages of Grails as a development framework. You definitely should be thinking of modularization of your functionality from the beginning and designing for plugin creation and use.
As you surmised, you use grails plugins for this purpose. We have developed an internal ecosystem that consists of (currently) some 30 plugins, each of which provides a specific piece of functionality. We have also carried forward some of the patterns visible in Grails plugins such that base functionality (domains and services) are held separate from user interface (controllers, taglibs and views). For example we have the following plugins:
arkCore - Core datatypes, domains and services
arkComponents - Common UI controls
arkDocument - Document management datatypes, domains and services
arkDocumentUi - Document management user interface
In this case arkDocument is dependent on arkCore and arkDocumentUi is dependent on arkDocument and arkComponents.
Grails can create either application or plugin projects. My recommendation is to
- Develop your functionality in one application to begin with.
- Get it working in some basic form.
- Create a plugin project and move all of the relevant artefacts from the application into the plugin.
- Publish the plugin to a local repository.
- Update project BuildConfig.groovy to reference the plugin the same as any other Grails plugin.
You will need to do the following things to get familiar with using plugins:
- Read and understand the plugins section of the Grails documentation
- Get and install Artifactory as a private plugin repository for your development. If it is just you, then you might just consider using the local Maven repository and using maven-install rather than publish-plugin.
- Look at some of the third party developed plugins for examples. They are generally very straightforward.