Question

I'm trying to build an annotation processor as eclipse plug-in. This is the first time I'm writing a plug-in for eclipse so I'm not sure I'm using the correct terminology and I'm sorry if I'm not perfectly clear.

My goal is to have a plug-in that generate code from annotated Java classes, I would like the plug-in to contains all the annotations, so beside installing the plug-in the user's project doesn't need to have additional dependencies, i.e. the user install the plug-in write some classes, annotate them with some annotations (packed inside the plug-in) and gets the generated code.

Is it possible to do what I'm trying to do ? I've seen some other plug-ins (Xtent for example) that add their own libraries.

10x

Était-ce utile?

La solution

It is possible. You need to implement a custom IClasspathContainer that dynamically resolves your plugin jar and adds the annotation classes to the project build path when the classpath container is on the build. In build path UI, IClasspathContainer goes by the name of "Library". Things like JRE, User Library, etc. are implemented via IClasspathContainer API.

To see examples, grab the source of org.eclipse.jdt.core and org.eclipse.jdt.ui plugins.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top