Weaving intertypes methods

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Weaving intertypes methods

This post has NOT been accepted by the mailing list yet.
Hi everybody,
I'm having some problem with intertyped methods declaration.
To avoid being forced to define an ID for every entity in my domain, I created an aspect that do that for every class marked as @javax.persistence.Entity.
With this aspect I add

private String id;
public String getId() {...}
public void setId(String id) {...}
// more methods

to entity classes.

When it comes to deploy, tests fail due to the lack of the method getId() in the test entity classes. I think it is because maven-compiler-plugin:testCompile is invoked before aspectj-maven-plugin:test-compile hence intertyped methods are not been weaved yet.

The aspectj-maven-plugin has diffent compile and test-compile configurations (because I have more aspect libraries int test-compile than in compile).

Currently I resoved by adding another execution to the plugin weaving aspects *also* in generate-test-sources phase.
This seems to work, but obviously some aspect are weaved more than once and I don't know if this can cause problems.

Can you suggest me a better solution?

Many thanks,