The Enterprise OSGi spec defines a manifest header, "Meta-Persistence", which marks an OSGi bundle as Persistence Bundle. Using this header, a user can also specify additional persistence.xml files to be applied:
So AFAICS also with the declarative approach some OSGi-specific code would be required which interprets this header (using a BundleTracker) and registers an associated entity manager factory service etc. But as you say the dependency to the required APIs could be optional/provided to not pull in any OSGi dependencies for non-OSGi environments.
The Enterprise OSGi spec defines a manifest header, "Meta-Persistence", which marks an OSGi bundle as Persistence Bundle. Using this header, a user can also specify additional persistence.xml files to be applied:
So AFAICS also with the declarative approach some OSGi-specific code would be required which interprets this header (using a BundleTracker) and registers an associated entity manager factory service etc. But as you say the dependency to the required APIs could be optional/provided to not pull in any OSGi dependencies for non-OSGi environments.