Two Laptop Bag
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
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply 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: 1271
    
    7

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: 5533

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How do I process compile time annotations from a Mojo
 
Similar Threads
Doubt in annotations.
Maven Project Running Problem
com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin not found
why the annotaion way
WEB-INF/classes/_pageflow folder missing using ant scripts