Search code examples
liferayliferay-6liferay-service-builder

How to have multiple service.xml in a single plugin


I have

  1. Single project - Test
  2. Multiple portlets in this project like - Test01, Test02, Test03.

I want to

  1. have services generated through service-builder.
  2. have services for different portlet to reside in different packages, like for liferay we have service.xmls as <service-builder package-path="com.liferay.portlet.documentlibrary"> and

Question

  1. Is there a way I can have multiple service.xml files for each portlet's services.
  2. If I can have multiple service.xml files then can I have the LocalService classes generated for different portlet in different packages like:
    1. For Test01: com.prakash.test.one.Test01LocalService
    2. For Test02: com.prakash.test.two.Test02LocalService
    3. For Test03: com.prakash.test.three.Test03LocalService

Any help would be appreciated.

Thanks


Solution

  • I found one solution looking at the source code of Liferay. It would require Liferay IDE.

    1. We can have multiple service.xml in there respective packages like com/prakash/test/one/service.xml, com/prakash/test/two/service.xml etc.
    2. Then we can build each service.xml individually.
    3. We can build the service by opening the service.xml in Liferay IDE. Then clicking the top-right corner icon to build the service or using shortcut Ctrl+Shift+B.
    4. It builds the services in their respective packages
    5. Also includes the consolidated *service.jar for the project in WEB-INF/lib/ as usual.

    Hope this helps somebody.