Avoiding code duplication between base project and addon in Jmix multi-store setup

Question:

I’m working on Jmix addons with a multi-store setup. I have:

  • A base project
  • An addon project (multi-store)

I’m facing an issue where multiple classes and entities are duplicated between the base and addon – they are exactly the same, except for their annotations.

Example:

Base Main Project:
package com.mcollect.digital_scheduler.entity;

@JmixEntity
@Table(name = “COMMUNICATIONS”)
@Entity(name = “SchedulerCommunication”)
public final class Communication {
// … same fields and logic
}

Addon Project:
package com.mcollect.digital.entity;

@JmixEntity
@Store(name = “digital”)
@Table(name = “COMMUNICATIONS”)
@Entity
public final class Communication {
// … same fields and logic
}

The problem: The entity logic is identical, but annotations differ (different package, @Store , @Entity name vs no name, etc.).

Question: How can I avoid this code duplication while minimizing the amount of code changes needed?