How to force specific Apache POI versions in base project and addon independently (Jmix 1.7.1)

I’m developing a Jmix addon that uses Apache POI for Excel generation, and I’m facing a common dependency version conflict scenario.

Base Project: Uses Apache POI version X (e.g., latest 5.3.0)

Addon Project: Needs to use Apache POI version Y (e.g., 4.2.3 due to specific compatibility requirements)

Both projects: Are Jmix-based with their own build.gradle files
The Core Challenge:

  • When an addon is included in a base project, Gradle’s dependency resolution mechanism kicks in. By default, Gradle will:
  • Resolve dependencies from both projects
  • Often pick the highest version during conflict resolution
  • Use a single version for all code at runtime

This becomes problematic when:

  • The addon requires a specific older version for compatibility
  • The base project needs to use a newer version
  • The library has breaking changes between versions
  • You’re publishing an addon for the Jmix Marketplace that needs to work with various base project versions

The Requirement:

  • Base Project: Must use Apache POI latest version (e.g., 5.3.0)
  • Addon Project: Must use Apache POI version 5.2.3 (different from base)
  • Each project should use its own specified version without interference
  • Both versions need to coexist at runtime

Hello Puneet!

Yes, Gradle resolves dependencies across the entire project and selects one version. Also, JVM loads only one class version per package. Loading the same class causes duplicate class errors.

Probably, Gradle’s Shadow plugin can help you. It can relocate classes of POI to another package. However it is not tested with Jmix and can be a cause of unpredictable behavior.

The best solution will be aligning POI versions if it is possible.