jmix icon indicating copy to clipboard operation
jmix copied to clipboard

Entities from subprojects can be lost

Open dtaimanov opened this issue 4 years ago • 1 comments

Problem

Some of dependency jars can be not assembled yet at enhancing time (mostly in case of multi-project builds). Entities from these jars is not considered in persistence.xml and orm.xml because they are absent in runtime classpath at enhancing step.

Reproduction

  1. Checkout branch feature/subproject-entities-lost_data-35
  2. run gradle clean build -x test AR: io.jmix.endata.entity.EnEntity is absent in sample-ui (see build/resources/main/io/jmix/samples/ui/persistence.xml) but present in api-depency module ui-endata (see build/resources/main/io/jmix/endata/persistence.xml) ER: EnEntity should be present in persistence.xml for both modules

Background

  1. ORM descriptor files (peristence.xml and orm.xml) are constructed at build time now.
  2. Entity from compileOnly dependencies should not appear in descriptor files because it will cause problems at build time: Haulmont/jmix-data#25 (solvable), and at runtime: because of .class absence (not solvable or hardly solvable)
  3. I've found just one reliable way to exclude compile-only entities: filter out entities that are absent in runtime classpath. (discussable)
  4. Entities cannot be filtered just by library names for multiproject builds: they appear as 'paths' in compile classpath and as 'jars' in runtime classpath (see Haulmont/jmix-core#62 and Haulmont/jmix-data#33)
  5. Because of differences in path representation (4) all entities collected separatly for compile classpath, runtime classpath and then intersection of this entities added to ORM descriptor files.
  6. Some entities can be lost because their jars is not constructed yet and their .class files are absent in runtime classpath at enhancing step

Possible solutions

  1. Find another reliable way to filter out compileOnly entities
  2. ["good" solution] Force gradle to run jar for dependency projects before compileJava for dependent project (e.g. ui-data jar is constructed before sample-ui. todo: investigate why this is not works in some other cases)
  3. Leave as is and show warning
  4. [optimal] Forbid compileOnly dependencies to modules with entities and skip absent entities from transitive dependencies of this modules (these entities will be absent in compile classpath too)

dtaimanov avatar Jan 13 '21 12:01 dtaimanov