Gradle not finding dependency while intellij sort-of-does

Hi.
Studio12 and 7.1.1 project on the road.
I did want to have my entities being notified upon modification so that i could fill some fields before persistence.
Found documentation for this at Entity Listeners - CUBA Platform. Developer’s Manual which was fine.
I decided to implement BeforeInsertEntityListener, but for some weird reason, intellij would not find com.haulmont.cuba.core.listener on import.
So what i did was to go to class definition and add “implements BeforeInsertEntityListener” so that maybe it would do its magic to get the import. Intellij told me it had to add the cuba core module. I accepted and then import was fine, i could override the listener method and all was fine.
Then i tried to compile and gradle would whine on the import, making intellij to be blind to it again. Project does not compile anymore due to this.

There must be some black magic somewhere but i can not sort it out. Is there something i forgot to do or did i just somewhat crash my project?

Thanks.

By the way, i tried various tips i got here and there:

  • manually clearing the cache for both gradle and m2
  • refreshing gradle from intellij
  • checking for empty cache directories that could bother it
  • removed all incorrect imports and related code, compiled, then added them again.

None of those made it work.

Also, here is what intellij proposes when i try to implement the listener. That looks wrong to me, it should already be the case, isn’t it?
47

Hi,

The problem is that if you try to implement a entity listener within an entity class.

The entity class is in the global modul. The entity listener interface is in the core module. Therefore IDEA wants to add the core dependency of cuba to the global module of your app.

Solution: create a dedicated class that acts as the entity listener in the core module of your application.

Cheers
Mario

1 Like

Thanks a lot, that worked.
I was not aware of those domain limitations. Will have to get more information about it to avoid doing same error again.