I have to use Annotation Processing (apt) and AspectJ in the same Maven project.
Both work for themselves, but I need to create aspects based on code created by apt. So I would need binary weaving (the original source files are extended by apt). How can I enable binary weaving within a maven project?
I know the only standard option is to supply a dependency using the weaveDependencies parameter, but this is awful. Is there any other way?
OK, I could embed the AspectJ ant tasks using the Maven Antrun Plugin but I’d hate to resort to that.
I am apparently the only one who can answer my own questions.
I have resorted to compiling AspectJ via ant using the Maven Antrun Plugin. Here’s my pom snippet:
I compile java classes first (and let APT do it’s stuff), use the compiled classes as binary input for aspectj, compile aspectj into a new folder and move the resulting woven classes to the original compile directory, overwriting the non-aspectj classes. Here’s my ant XML file (the nice part is that I can use it for both compile and test-compile):
In the next step I have now created a Maven Plugin that does all this ant calling internally. While I can’t share the code here, I’ll show how it simplified POM configuration:
Using ANT / GMaven integration, it was easy to assembly the parameters combining the powers of Maven, Groovy and Ant.