aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How do I process compile time annotations from a  Mojo Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How do I process compile time annotations from a  Mojo" Watch "How do I process compile time annotations from a  Mojo" New topic
Author

How do I process compile time annotations from a Mojo

Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2337
    
  28

I have couple of modules that have the following

a) A bunch of XML files
b) A custom compile time Annotation on several java files
c) A bunch of other resources that contain snippets of the final artifact.

All these need to be processed to create a single artifact. So, right now what we have done is
a) Implement a Mojo that converts the XML to a snippet of the artifact
b) Implement an Annotation processor that generates snippets of the artifact by processing the compile time annotation
c) Implement another mojo that merges the 3 snippets together into one artifact

We have to run this process twice because there are minor differrences in the artifact that is used for unit testing vs the artifact used for production

Everything works fine, but the problem is my pom.xml is very big. I have 2 of my own plugins and maven processor plugin. Both of my plugins have 2 executions, one for production, one for test. Also, the final artifact is being created by 3 seperate plugins, fixing problems is kind of a pain

I wanted to merge all 3 functions into one MOJO. I can merge my 2 Mojos easily, but how do I process compile time annotations from my Mojo?. Is there a code sample available somewhere?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

The Annotation processor is just some Java code, right? Couldn't you invoke that code directly from your mojo? If nothing else, you could always directly call the main() method of the main class. Though most likely that just does some processing of the arguments and then calls another class - it is that class that you really want to call.


JBoss In Action
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do I process compile time annotations from a Mojo