java.is.for.desktop
java.is.for.desktop

Reputation: 11216

Java: How to communicate between an annotation processor and another project?

I have an own annotation processor (let's call it MyProcessor) and a project (let's call it MyProject) which uses the processor by passing -processor to javac.

Now I need MyProcessor to produce some output and make it available for MyProject.

I have following options (and problems):

Can someone please suggest, how to proceed?

Upvotes: 1

Views: 747

Answers (1)

ChssPly76
ChssPly76

Reputation: 100706

Processor.init() method (which you've implemented) is invoked with ProcessingEnvironment as parameter which, in turn, has a getFiler() method returning a Filer instance.

You should be using the createResource() method of the Filer (assuming the output being generated is neither class nor source; otherwise use appropriate create method for that) and write your output to either class or source locations (former is probably preferable, but it depends on what you're doing). Both are overridable via command-line switches if need be, but are well-defined as they are to be used in a build process.

Upvotes: 4

Related Questions