File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I process compile time annotations from a Mojo

 
Jayesh A Lalwani
Rancher
Pie
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic