Prabhath
Prabhath

Reputation: 629

Differences between adding a project as dependency and as a plugin

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.

Upvotes: 0

Views: 191

Answers (1)

Steve Hole
Steve Hole

Reputation: 358

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.

Upvotes: 2

Related Questions