DataNucleus and Maven2

Apache Maven is a project management and build tool that is quite common in organisations. It continues on from where Maven1 left off though not providing backwards compatibility with Maven1.


The main thing that you need to bear in mind is that DataNucleus jars are present in DataNucleus own Maven repository so all you need to do is point your Maven2 project at this repository. You do this by including the following in your pom.xml


            <name>DataNucleus Repository</name>
        <repository> <!-- Required for transaction-api transitive dep -->
            <name>Java.Net legacy</name>

So this make the DataNucleus Maven2 repository available, and also makes the DataNucleus Maven2 plugin available.

Maven2 Plugin

Now that you have the DataNucleus jars available to you, via the repositories, you want to perform DataNucleus operations. The primary operations are enhancement and SchemaTool (for RDBMS). To run the enhancer you do

mvn datanucleus:enhance

If you want this to be done automatically after compiling then you should add the following into your pom.xml


So whenever compile takes place it then does an enhance using the DataNucleus Maven2 plugin. See also the Enhancer docs

RDBMS SchemaTool is achieved similarly, via

mvn datanucleus:schema-create

See also the RDBMS SchemaTool docs