Hi all,
For the last week, I'm trying to get a maven plugin (nl.topicus.plugins:javassist-maven-plugin) working in Eclipse, but to no avail. After consulting with the m2e-devs, they advised me to ask here.
The problem I'm facing is best demonstrated with a small application, which can be found at https://github.com/papegaaij/maven-javassist-demo . This maven project has 4 modules with 3 classes in total (you have to install the transformer module in your local repository, because m2e cannot resolve workspace projects as plugin dependencies):
base-classes: It contains a single class nl.topicus.HelloWorld with a perform method that always throws UnsupportedOperationException.
transformer: The class nl.topicus.DemoTransformer is used by the javassist-maven-plugin to replace the HelloWorld.perform method with a real 'Hello world!'
transformed-classes: This module contains no code, only the plugin configuration for the javassist-maven-plugin. The plugin reads the compiled HelloWorld.class from base-classes and uses DemoTransformer to replace the perform method. The result is written in target/classes in transformed-classes (a new class file is written, the old one in base-classes is left intact).
demo: This module depends only on transformed-classes and contains nl.topicus.Demo, which invokes the transformed HelloWorld.perform to write 'Hello world!'.
On the command line, this project compiles fine. Running mvn exec:java in demo also shows the 'Hello world!'.
In Eclipse nl.topicus.Demo does not compile. It is missing the transformed HelloWorld class, even though it is on the classpath in transformed-classes/target/classes with the right contents (also visible in the Eclipse project explorer). Running Demo displays an unresolved compilation problem.
What's even stranger is that creating an empty src/main/java in transformed-classes fixes the compile error, but only in the project explorer and the problems view. When the Demo.java file is opened in the editor, Eclipse still displays the error and type completion also does not work. This time it runs fine though.
I could really use some help in this, as I've been trying to get this working for over a week now. It seems as if Eclipse requires java source files to recognize generated classes. Do I need to change something in the project configuration of either transformed-classes or demo for the class file to be picked up or did I hit a limitation in how Eclipse resolves types?
Best regards,
Emond Papegaaij |