This document explains the static weaving setup for JPA entities in the Fineract project.
Static weaving is a process that enhances JPA entities at build time to improve runtime performance. This is done using the org.eclipse.persistence.tools.weaving.jpa.StaticWeave which processes the compiled classes and applies the necessary bytecode transformations.
The static weaving is configured in static-weaving.gradle and applied to all Java projects that contain JPA managed classes.
- Compilation: Java source files are compiled to the standard classes directory (
build/classes/java/main). - Persistence metadata generation: The build scans the current module and its transitive project runtime dependencies for JPA entities, mapped superclasses, and converters. It generates
build/tmp/compileJava/static-weaving/META-INF/persistence.xml. - Weaving: Weaving happens as the last step of the compileJava task, which outputs enhanced classes to the standard classes directory (
build/classes/java/main).
- Add JPA entities to
src/main/java - Add project dependencies normally in Gradle
- The build will automatically detect and apply static weaving
Do not add module-level static-weaving persistence.xml files under src/main/resources/jpa/static-weaving; the build generates the weaving metadata.
If you encounter issues with static weaving:
- Check the generated
build/tmp/compileJava/static-weaving/META-INF/persistence.xml - Verify that the output directories are being created correctly
- Check the build logs for any weaving-related errors