Modularize Grails应用程序(Grails 2.3.x) [英] Modularize Grails Application (Grails 2.3.x)

查看:107
本文介绍了Modularize Grails应用程序(Grails 2.3.x)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Grails中开始我的第一个项目,并且我想分割更多的应用程序/插件。



现在我只有一个站点/应用程序( / myproj / projectA )。在将来,我想添加一个新的应用程序( / myproj / projectB ),我想重用一些projectA(例如UserService)的逻辑。



在Grails中,这是什么方式?创建2个应用程序( projectA,projectB )和一个common(ex.with UserService)插件?

这是怎么回事?



最终结果是:我想更新单个应用程序而无需重新部署整个应用程序。

预先致谢

解决方案

创建可重用/共享功能是Grails作为开发框架的关键优势之一。你肯定应该从一开始就考虑你的功能的模块化,并设计插件的创建和使用。



正如你猜测的那样,你使用grails插件来达到这个目的。我们开发了一个内部生态系统,其中包括(目前)大约30个插件,每个插件都提供了一个特定的功能。我们还推出了Grails插件中可见的一些模式,使得基本功能(域和服务)与用户界面(控制器,标签库和视图)保持分离。例如,我们有以下插件:

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ arkCore - 核心数据类型,域和服务$ b $ arkComponents - 通用UI控件
arkDocument - 文档管理数据类型,域和服务
arkDocumentUi - 文档管理用户界面

在这种情况下,arkDocument依赖于arkCore,而arkDocumentUi依赖于arkDocument和arkComponents。



Grails可以创建应用程序或插件项目。我的建议是


  1. 在一个应用程序中开发您的功能以开始。

  2. 让它工作以一些基本的形式。

  3. 创建一个插件项目,并将所有相关的人工制品从应用程序移动到插件中。 发布插件到本地存储库。

  4. 更新项目BuildConfig.groovy以引用与任何其他Grails插件相同的插件。

您需要做以下事情才能熟悉使用插件: 阅读并理解Grails的插件部分文档

  • 获取并安装Artifactory作为您的开发的专用插件存储库。如果只是你,那么你可以考虑使用本地Maven仓库,并使用maven-install而不是publish-plugin。

  • 查看一些第三方开发的插件示例。它们通常非常简单。


  • 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

    1. Develop your functionality in one application to begin with.
    2. Get it working in some basic form.
    3. Create a plugin project and move all of the relevant artefacts from the application into the plugin.
    4. Publish the plugin to a local repository.
    5. 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.

    这篇关于Modularize Grails应用程序(Grails 2.3.x)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆