I’m not sure if it’s even possible…
I have some design patterns, which I want in my special Maven package (#1) – all these patterns use javax.persistence. I don’t want this package to depend on Hibernate or any other implementation of JPA. Just let it depend on JPA API, as it is defined by JCP.
My second Maven package (#2) is to use this first one, and to specify which JPA implementation to use (f.e. Hibernate).
Now, how do I define my pom.xml for both of these packages (let JPA implementer for #2 package be Hibernate)?
JPA defines a package
javax.persistence, it contains Annotations, Interfaces and so on. This package is completely Provider independent. It should contains every thing you need to implement provider independent services basd on JPA.The only thing you need is to put an dependency to an
javax.persistencecontaining maven artifact in your Maven module #1.There are several maven artifacts containing this
javax.persistencepackage. For example:In you Maven Module #2 you need to put an dependency to Module #1 and an dependency to the JPA provider (for example Hibernate) you like to use.
(If the provider you use, use an other dependency to the
javax.persistencepackage, then you need to exclude one of them.)