Here, I will be sharing my experience and thoughts on the component and the code-base management for a Liferay project.
You can use either ANT or Maven for the code base management. I would say Maven is a good choice for modular architecture.
Lets get back to the topic.
In Liferay, a portlet, hook, web, theme, layout template, all are web applications. When you create them and deploy, it will be deployed as a separate web application in an application server. Considering this fact, more number of components will create more number of web apps and at the later stage will require more maintenance.
You can actually create many portlets, themes, layouts, hooks in a single web app. Also, you can mix and match. Meaning, a single web application can contain a portlet and a theme also or any other components.
Lets say, we are creating a web application for a brand called "Epic". And like any other web application, this has various features like user authentication, user profile management, content management, payment gateway integration, look and feel components, document management, third party service integration etc.
So, how should we start? Well.. lets start then
List down the components
In our case, I am listing down some components
- user authentication hook (our backend uses some third party authentication)
- user my profile portlet
- liferay-hook (for liferay jsp modification and language properties)
- epic theme (a new theme for look and feel)
- 1-2-2-1 layout (assuming we need some new liferay page layout template)
- order-processing portlet
aah.. that is enough.. we can scale that later. Lets move on.
Logically divide and combine components
How? Let us say that our features user authentication, user my profile portlet and liferay-hook (containing login.jsp of Liferay) contain the component and features that are related with user .authentication and management process.
So create a component called "epic-user-management-component". You can create this by using maven commands of Liferay. Give a name ending with "component" and not "portlet". Maven has created a portlet for you, but we can make this as a component.
Since, this is maven module is a type of "portlet", it has a standard portlet.xml and liferay-portlet.xml and etc. In a nutshell, it has a project nature "portlet". the portlet.xml and liferay-portlet.xml can have multiple "portlet" tags and thus it can contain more than one portlets.
So, any portlet that has a logical / business nature of "user-management" should go here. Now, let say, that you have also modified the liferay "login.jsp" for the same. So, you need a hook. Simple add the "liferay-hook.xml" in the "epic-user-management-component" and also, copy the customized jsp into webapps and also configure the path of that.
Your component has now 2 project natures. A portlet and a hook. Let say that you have also modified the liferay user services for the same, or you have created a new services for authentication Simple add the "service.xml" of your new components and build the liferay service. Your "epic-user-management-component" can now serve the new services as well. Same can be done for theme and layouts. By adding liferay-look-and-feel.xml or by liferay-layout-templates.xml will make the component with a nature of theme and layout-template.
So, you component is now acting as a portlet, a service provider, a hook and so on. Also, defining the dependency for this component is easy and simple, the pom.xml of this component will have all the dependencies that you require for user management.
The second component can be an "epic-look-and-feel-component". This component can contain all the custom themes, layouts, any Liferay jsps that you have modified for look and feel, some custom images that you want to inject directly to /ROOT (liferay portal web app) and etc.
The third component can be an "epic-localization-component" this component can contain all your language properties, custom language properties, Liferay jsps that you have modified for internationalization, and third party service components that you want to use for internationalization.
And all other components can be divided based on the use case or feature.
So, if you divide your features or components like this, it will have less web applications, the related components are together and they can share the same dependencies on the same class path.
Your code base will look like