A maven mixin that provides datanucleus:enhance plugin (for JDO entities of DN modules)
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.adoc
bumpver.sh
pom.xml
release.sh

README.adoc

java-mavenmixin-datanucleusenhance

This module provides a maven mixin that can be incorporated into Maven module that contains JDO/DataNucleus entities that require enhancing. This reduces the size of the maven pom.xml file for that consuming module; it simply needs to reference this module using the mixin-maven-plugin.

The appropriate datanucleus plugins/configuration are included in a <profile> which is automatically included in all builds. If necessary this profile can be disabled using a Maven property.

Note

This module was initially developed for use within Apache Isis applications but can be used by any application that uses JDO/DataNucleus as its ORM.

How to Configure

To configure:

  • copy and paste the following into either the pom.xml of the consuming module or (better still) the pom.xml of the top-level parent of the consuming module:

    <properties>
        ...
        <mavenmixin-datanucleusenhance.version>0.0.5</mavenmixin-datanucleusenhance.version>
    
        <datanucleus-maven-plugin.version>5.0.2</datanucleus-maven-plugin.version>
        <datanucleus-core.version>5.1.5</datanucleus-core.version>
        <datanucleus-api-jdo.version>5.1.4</datanucleus-api-jdo.version>
        <datanucleus-jodatime.version>5.1.0-release</datanucleus-jodatime.version>
        ...
    </properties>

    and:

    <build>
        <pluginManagement>
            <plugins>
                ...
                <plugin>
                    <groupId>org.datanucleus</groupId>
                    <artifactId>datanucleus-maven-plugin</artifactId>
                    <version>${datanucleus-maven-plugin.version}</version>
                </plugin>
                ...
            </plugins>
        </pluginManagement>
    </build>
  • update the following property/ies in the pom.xml of the consuming module (containing the JDO/DataNucleus entities):

    <properties>
        ...
        <datanucleus-maven-plugin.log4jConfiguration>${basedir}/logging-dn-enhance.properties</datanucleus-maven-plugin.log4jConfiguration>
        <datanucleus-maven-plugin.verbose>true</datanucleus-maven-plugin.verbose>
        <datanucleus-maven-plugin.fork>false</datanucleus-maven-plugin.fork>
        ...
    </properties>

    These correspond to the equivalent <configuration> parameters of the datanucleus enhancer. If not set, then the values shown above are the defaults.

  • add the following to the pom.xml of the consuming module:

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.odavid.maven.plugins</groupId>
                <artifactId>mixin-maven-plugin</artifactId>
                <version>0.1-alpha-39</version>
                <extensions>true</extensions>
                <configuration>
                    <mixins>
                        <mixin>
                            <groupId>com.danhaywood.mavenmixin</groupId>
                            <artifactId>datanucleusenhance</artifactId>
                            <version>${mavenmixin-datanucleusenhance.version}</version>
                        </mixin>
                    </mixins>
                </configuration>
            </plugin>
        </plugins>
    </build>
  • include a log4j configuration file matching the name of the log4jConfiguration property.

    For example:

    log4j.appender.A1=org.apache.log4j.FileAppender
    log4j.appender.A1.File=datanucleus.log
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
    
    # overriding all those below...
    log4j.category.DataNucleus=ERROR
    
    log4j.category.DataNucleus.Persistence=INFO, A1
    log4j.category.DataNucleus.Transaction=INFO, A1
    log4j.category.DataNucleus.Connection=INFO, A1
    log4j.category.DataNucleus.Query=INFO, A1
    log4j.category.DataNucleus.Cache=INFO, A1
    log4j.category.DataNucleus.MetaData=INFO, A1
    log4j.category.DataNucleus.Datastore=INFO, A1
    log4j.category.DataNucleus.Datastore.Schema=INFO, A1
    log4j.category.DataNucleus.Datastore.Persist=INFO, A1
    log4j.category.DataNucleus.Datastore.Retrieve=INFO, A1
    #Log of all 'native' statements sent to the datastore
    log4j.category.DataNucleus.Datastore.Native=INFO, A1
    log4j.category.DataNucleus.General=INFO, A1
    #All messages relating to object lifecycle changes
    log4j.category.DataNucleus.Lifecycle=INFO, A1
    log4j.category.DataNucleus.ValueGeneration=INFO, A1
    log4j.category.DataNucleus.Enhancer=INFO, A1
    log4j.category.DataNucleus.SchemaTool=INFO, A1
    log4j.category.DataNucleus.JDO=INFO, A1

    If the configuration property has not been overridden, this will be called logging-dn-enhance.properties file in the base of the module(s).

To disable the (profile contributed by this) mixin, pass the following system property to mvn:

mvn -Dskip.mavenmixin-datanucleusenhance

Known issues

None currently

Change Log

  • 0.0.5 - updates to DataNucleus 5.1.5

  • 0.0.4 - updates README for properties and plugin management, shortens property names and profile id

  • 0.0.3 - fixes #1 - now also enhances test classes; in addition, exposes additional optional configuration properties.

  • 0.0.2 - allow the log4jConfiguration property to be optionally specified by consuming module; change the name of the profile used to release via Sonatype OSS repository

  • 0.0.1 - for DataNucleus 4.0.1

License

Copyright 2016~date Dan Haywood

Licensed under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Dependencies

This mixin module relies on the com.github.odavid.maven.plugins:mixin-maven-plugin, released under Apache License v2.0.

Maven deploy notes

The module is deployed using Sonatype’s OSS support (see user guide and this blog post).

The release.sh script automates the release process. It performs the following:

  • performs a sanity check (mvn clean install -o) that everything builds ok

  • bumps the pom.xml to a specified release version, and tag

  • performs a double check (mvn clean install -o) that everything still builds ok

  • releases the code using mvn clean deploy

  • bumps the pom.xml to a specified release version

For example:

sh release.sh 0.0.5 \
              0.0.6-SNAPSHOT \
              dan@haywood-associates.co.uk \
              "this is not really my passphrase"

where

  • $1 is the release version

  • $2 is the snapshot version

  • $3 is the email of the secret key (~/.gnupg/secring.gpg) to use for signing

  • $4 is the corresponding passphrase for that secret key.

Other ways of specifying the key and passphrase are available, see the pgp-maven-plugin's documentation).

If the script completes successfully, then push changes:

git push origin master
git push origin 0.0.5

If the script fails to complete, then identify the cause, perform a git reset --hard to start over and fix the issue before trying again. Note that in the dom’s `pom.xml the nexus-staging-maven-plugin has the autoReleaseAfterClose setting set to true (to automatically stage, close and the release the repo). You may want to set this to false if debugging an issue.

According to Sonatype’s guide, it takes about 10 minutes to sync, but up to 2 hours to update search.