DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Branden Visser
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Tools : Maven plugin

Documentation: Add plugin dependency for datanucleus-api-jdo or datanucleus-api-jpa

Created: 22/Jun/12 10:24 PM   Updated: 16/Oct/12 11:41 AM   Resolved: 25/Jun/12 03:49 PM
Component/s: None
Affects Version/s: 3.1.0.m3
Fix Version/s: None

 Description  « Hide
This is just a documentation suggestion. For multi-project maven projects, when not all projects may import the jdo artifacts, if you have the datanucleus:enhance plugin on the lifecycle the plugin will fail. Since the dependencies are required, consider adding a documentation change to suggest adding the plugin dependencies similar to this:


Doc location:

Sort Order: Ascending order - Click to sort in descending order
Branden Visser added a comment - 22/Jun/12 10:43 PM
It appears that if you do this, then you get a "duplicate plugin" error when a project actually has the datanucleus-api-jdo artifact. My bad.

I suppose deep down this is a request to be able to suppress this error and continue normally:

[ERROR] --------------------
[ERROR] Standard error from the DataNucleus tool + org.datanucleus.enhancer.DataNucleusEnhancer :
[ERROR] --------------------
[ERROR] Jun 22, 2012 4:41:49 PM org.datanucleus.enhancer.DataNucleusEnhancer <init>
INFO: DataNucleus Enhancer : Using ClassEnhancer "ASM" for API "JDO"
Jun 22, 2012 4:41:50 PM org.datanucleus.api.ApiAdapterFactory getApiAdapter
SEVERE: Error : Could not find API definition for name "JDO". Perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?
Exception in thread "main" Error : Could not find API definition for name "JDO". Perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?
org.datanucleus.exceptions.NucleusUserException: Error : Could not find API definition for name "JDO". Perhaps you dont have the requisite datanucleus-api-XXX jar in the CLASSPATH?
at org.datanucleus.api.ApiAdapterFactory.getApiAdapter(
at org.datanucleus.NucleusContext.<init>(
at org.datanucleus.NucleusContext.<init>(
at org.datanucleus.enhancer.DataNucleusEnhancer.<init>(
at org.datanucleus.enhancer.DataNucleusEnhancer.main(

Andy Jefferson added a comment - 25/Jun/12 03:49 PM
The docs (now) mention the explicit need to include datanucleus-api-jdo or datanucleus-api-jpa in the CLASSPATH (whether plugin, or project). There are obviously 2 ways a Maven plugin can operate
1. Include all jars itself in the CLASSPATH via the plugin pom.xml (on top of the projects jars).
2. Leave it to the user to do it (assuming they are in their project).

No way caters for all cases. There doesn't seem to be any standard Maven way of cater for this either. Obviously people can contribute patches (to the M2 plugin) if they find some way that works for all.

Branden Visser added a comment - 25/Jun/12 04:07 PM
Thanks for your feedback on the issue, Andy. For now, users will have to include the plugin only on projects that will have @PersistenceCapable entities, which is a reasonable way to go.

I haven't looked at the M2 plugin source yet, but I'd be happy to contribute resources to this approach if you agree with its value:

1. Scan for enhance-able objects before trying to fire up the NucleusContext
2. If there are no entities to enhance, bypass -- no error thrown, and no dependency on jdo-api or jpa-api is required
3. If there are entities to enhance, fire up NucleusContext and let it fail if the dependencies are not present

We have a parent POM that we'd like to include datanucleus:enhance in to keep JDO project POMs lean, a large number of projects that inherit from it, and not all will necessarily have JDO persistent entities.


Andy Jefferson added a comment - 25/Jun/12 05:21 PM
Your approach may work ... for some use-cases; obviously be aware that a Maven plugin can be using fork=true or fork=false so there are both sides to (ultimately) cater for. Another factor is that the enhancer can be run from a persistence-unit and you need to process the metadata in that situation before knowing if there is anything to do. Maybe other situations that I haven't thought of will impact on it