Search code examples
liferayliferay-7liferay-service-builderliferay-7.1

Using service builder generated classes in other modules


I'm using Liferay 7.1 GA1 Version. I have generated my service/api java classes with service-builder that Liferay IDE provides me.

How can I use these service classes in my other modules? I would like to use "MyServiceBuilder" generated classes in "MyPortlet" like you can see in the following picture.

Thanks.

Picture


Solution

  • Structure your project like this:

    structure

    in the gradle file of the portlet add:
    compileOnly project(":modules:test-service:test-service-api")

    Right click and select Gradle > Refresh Gradle Project on the test-service folder.

    Then use OSGi Declarative Services in your portlet:
    @Reference
    protected FooLocalService _fooLocalService;