Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dali » Using Dali annotation processor from a maven build
Using Dali annotation processor from a maven build [message #718450] Wed, 24 August 2011 07:30 Go to next message
apfryer is currently offline apfryer
Messages: 2
Registered: August 2011
Junior Member
I am currently using maven and eclipse and have a JPA project as one of the maven modules. I can build everything fine and have the JPA project configured to automatically generate the metamodel classes in a specified directory. The maven build of the project also builds the metamodel classes into the same folder but uses a different annotation processor (openjpa or eclipselink).

In the generated classes, this is always a @Generated annotation, which for eclipselink looks like this...

@Generated("EclipseLink - Wed Aug 24 21:20:08 EST 2011")

The problem I have is that when the @Generated annotation value isn't "Dali", then when I make changes to entity classes in eclipse, the metamodel classes won't be automatically updated/overwritten. If i manually change the @Generated value to "Dali", it all starts working again. This is probably the expected behaviour but gives me a problem so that when I do a maven build, i lose the capability to have my metamodel classes automatically updated. I have to manually delete the metamodel classes and allow Dali to regenerate them.

I was thinking that a solution to this problem would be to invoke the Dali annotation processor from the maven build, instead of eclipselink or openjpa. That way, hopefully the @Generated value would be "Dali" and then Dali would continue to overwrite the metamodel classes as changes to the entity classes were made.

I'm assuming it would be possible to do this if I had
a) a maven dependency that contained the Dali annotation processor class
b) the compiler options required to pass to the Dali annotation processor

Can anyone help out with this information?
Re: Using Dali annotation processor from a maven build [message #719261 is a reply to message #718450] Fri, 26 August 2011 10:32 Go to previous messageGo to next message
Neil Hauge is currently offline Neil Hauge
Messages: 467
Registered: July 2009
Senior Member
This behavior is as-designed as you expected. I guess the general problem here is that you are using two different methods to generate your metamodel. Ideally your maven build would use the same metamodel generation approach to ensure that you get the same results as your dev-time. The problem is that Dali doesn't use an annotation processor to generate the metamodel. We simply build the metamodel from our always up-to-date Dali model. Currently there is no way to invoke this metamodel generation from outside of a Dali project.

We could add a force option to our metamodel generation to overwrite other files of the same name, but this doesn't feel like the right solution. I think it is important that you unify your metamodel generation to ensure the same results. In order to do this, we would need to provide a way to run the Dali metamodel generation externally. Please feel free to enter an enhancement request in bugzilla for this. Other options for you would be to configure the non-Dali annotation processor to run on the Eclipse incremental compile. This would produce a similar effect as using the Dali based generation, although a less desirable experience (in both configuration and use).

Let me know if you have other thoughts on this.

Neil

Re: Using Dali annotation processor from a maven build [message #719784 is a reply to message #719261] Sun, 28 August 2011 21:44 Go to previous messageGo to next message
apfryer is currently offline apfryer
Messages: 2
Registered: August 2011
Junior Member
Thanks for your reply Neil.

My thoughts were pretty much the same as yours. Either somehow specify Dali to always overwrite metamodel files, or create a Dali annotation processor that can be accessed externally. I also wondered about the rightness of allowing Dali to overwrite a metamodel file generated by a different annotation processor. The other annotation processors don't seem to have any problem overwriting the Dali generated metamodel files, so maybe its not as bad as it feels. Maybe so long as it has a @Generated annotation it is ok to overwrite it, or you could configure the @Generate values that you allow Dali to overwrite. I'm thinking that's probably the easier/quicker solution to implement compared to making a Dali annotation processor that can be externally invoked. I didn't want to go down the path of using a non-Dali annotation processor in the eclipse incremental build.

I submitted enhancment request 356036 as suggested for creating a Dali annotation processor.

Cheers,

Anthony
Re: Using Dali annotation processor from a maven build [message #719951 is a reply to message #719784] Mon, 29 August 2011 10:43 Go to previous message
Neil Hauge is currently offline Neil Hauge
Messages: 467
Registered: July 2009
Senior Member
Thanks for the feedback. I think the overwrite option is worth further consideration as you suggest. Given non-default user direction to overwrite other generated files is probably reasonable.

Neil
Previous Topic:JPA Diagram editor 0.5.0 not working with Graphiti 0.8.0
Next Topic:Dali, Toplink (GlassFish) and DB2
Goto Forum:
  


Current Time: Sat Jul 26 05:11:06 EDT 2014

Powered by FUDForum. Page generated in 0.04196 seconds