Circular dependency issue

Jamie Sammons, modified 3 Years ago. New Member Posts: 4 Join Date: 5/17/22 Recent Posts

I am using Liferay 7.3.7 ga8. I am wondering how to best approach the following:

- I want to extend a module (e.g. social-activities-web)

- I created my own module e.g. my-social-activities (**). My module needed some internal classes from social-activities-web. So I used fragment to export the internal classes. (*)

- After defining new implementation of my-social-activities e.g. NewSocialActivitiesDisplayContext. I once again need to change the fragment and e.g. add lines of code in init-ext.jsp (***).

The problem is when I run gradlew clean deploy, it seems that there are circular dependencies issues. My module, social-activities-web and fragment started and stopped all the time. I think the problem is the following: My module depends on internal classes aka fragment, but then the code in init-ext.jsp depends on my module and seem to lead to circular dependencies issue. Is there a better way to implement this? I am quite new to liferay and thanks in advance.

 

thumbnail
Olaf Kock, modified 3 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Circular dependencies are typically resolved through introducing a third module, on which both previous modules depend. This way, the dependency is unidirectional.

If you absolutely object to add another module, you can also merge the two current modules into just one.

Which of the solutions is best depends on the size of both and your future plans with the module(s)