将项目添加为依赖项和插件之间的差异 [英] Differences between adding a project as dependency and as a plugin

查看:151
本文介绍了将项目添加为依赖项和插件之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如:

$ b $在模块化Grails应用程序时,将模块作为插件添加到gradle依赖关系是什么时候有意义? b


  1. akaDomain 包含所有域对象。 演示逻辑。
  2. akaService1 包含一些服务。
  3. akaService2 包含一些其他服务。

所有网站和服务共享



akaDomain 中存在的域类是否可用于其他应用程序中的脚手架控制器和视图,如 akaService akaWebsite

>

这可以通过插件还是依赖或两者来实现。
请解释我缺少 akaDomain 的插件是什么。



answer 使用插件来解释如何模块化Grails应用程序。

解决方案

绝对可以将在一个插件中定义的域用作另一个插件或主应用程序中脚手架的基础。但是,如果您选择在插件中实现用户界面,那么您需要承诺以下几个方面的实际考虑: 一个用户界面的外观将在多个应用程序之间共享。在进行定制/合同开发时,这往往非常困难,因为每个客户都希望拥有自己的个人外观和感觉。至少在选择一个UI抽象的时候,你会想要考虑灵活的主题支持。我们使用Twitter Bootstrap来实现此目的,但还有其他几个方法可以满足您的要求。 UI插件。任何插件生态系统都是如此,但是一旦你承诺抽象化,这个规则就非常重要,否则你最终会遇到依赖性死角或周期。这是很多工作,但生产力的回报是非常高的。 插件与Gradle依赖关系:插件实际上是Gradle依赖关系(至少在Grails 3.x中)。也就是说,插件依赖管理是在Gradle之上实现的。插件为集成到Grails应用程序中提供了额外的支持,包括如下内容:




  • 启动时自动发布spring bean注册和初始化。

  • 参与应用程序组件的重新加载。

  • 启动时的人工定义和初始化。


    因此,使用插件来实现两全其美。


    When modularizing a grails application, when does it make sense to add the module as a plugin vs gradle dependency?

    For Example:

    1. akaDomain contains all the domain objects.
    2. akaWebsites contains all the presentation logic.
    3. akaService1 contains some services.
    4. akaService2 contains some other services.

    All the websites and services share akaDomain.

    Can the domain classes present in akaDomain be used for scaffolding controllers and views in another application like akaService and akaWebsite?

    Can this be achieved using plugins or dependency or both. Please explain what am I missing if I don't make a plugin of akaDomain.

    This answer uses plugin to explain how to modularize grails app.

    解决方案

    You can definitely use the domains defined in one plugin as the basis for scaffolding in another plugin or in a main application. There are several practical considerations when doing so however:

    • If you choose to implement UI in a plugin, then you are committing to a UI look and feel that is to be shared across multiple applications. This is often very difficult when doing custom / contract development where every customer wants their own personal look and feel. You will want to think about selecting a UI abstraction as well that allows flexibility on theme support at least. We use Twitter Bootstrap for this purpose but there are several others that fit the bill.

    • You must manage the dependencies between the "domain/service" and the "UI" plugins. This is true of any plugin ecosystem, but once you commit to abstraction, this discipline is very important or you end up with dependency dead ends or cycles. It is a lot of work, but the pay off for productivity is very high.

    As for the question on Grails Plugins vs Gradle dependencies:

    Plugins are in fact Gradle dependencies (in Grails 3.x at least). That is, plugin dependency management is implemented on top of Gradle. Plugins provide additional support for integrating into a Grails application that include things like:

    • Automated spring bean registration and initialization at startup.
    • Participation in application component reloading.
    • Artefact definitions and initialization at startup.

    So, implement using plugins and you get the best of both worlds.

    这篇关于将项目添加为依赖项和插件之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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