jmix
jmix copied to clipboard
Entities from subprojects can be lost
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
- Checkout branch
feature/subproject-entities-lost_data-35
- run
gradle clean build -x test
AR:io.jmix.endata.entity.EnEntity
is absent insample-ui
(see build/resources/main/io/jmix/samples/ui/persistence.xml) but present in api-depency moduleui-endata
(see build/resources/main/io/jmix/endata/persistence.xml) ER:EnEntity
should be present in persistence.xml for both modules
Background
- ORM descriptor files (
peristence.xml
andorm.xml
) are constructed at build time now. - 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) - I've found just one reliable way to exclude compile-only entities: filter out entities that are absent in runtime classpath. (discussable)
- 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)
- 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.
- 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
- Find another reliable way to filter out compileOnly entities
- ["good" solution] Force gradle to run
jar
for dependency projects beforecompileJava
for dependent project (e.g.ui-data
jar is constructed beforesample-ui
. todo: investigate why this is not works in some other cases) - Leave as is and show warning
- [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)