Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] Transforming class files in an M2E extension

If I read this correctly, you want to have both the transformer and the
classes to be transformed in your workspace. This means that Eclipse
workspace will have to first compile transformer classes and them
immediately execute them. Even if this can be done, which I am not sure,
I strongly advice against this because problems with transformer can
crash your eclipse instance, for example. Tracking dependency between
transformer and classes to be transformed is another problem. You
probably want to move transformer to a separate project, deploy to a
maven repository and consume it in a binary form.

As for manipulating .class files inside Eclipse workspace, this is kinda
tricky. I believe the correct way to do this is to implement
org.eclipse.jdt.core.compiler.CompilationParticipant but this most
likely means duplicating logic from javassist-maven-plugin. Wiki [1]
gives some pointers how to "map" javassist-maven-plugin to m2e
extension, but I don't have example that show use of CompilationParticipant.

"Less" correct way, which may or may not work, is to invoke
javassist-maven-plugin during Eclipse workspace build. I would recommend
changing javassist-maven-plugin to use BuildContext API as explain in
wiki [2]


[1] http://wiki.eclipse.org/M2E_Extension_Development
[2] http://wiki.eclipse.org/M2E_compatible_maven_plugins

--
Regards,
Igor

On 1/18/2014, 10:46, Emond Papegaaij wrote:
Hi all,

Having some issues with a maven plugin that transforms class files in
M2E (endless builds), I decided to try to write an extension (my first)
that handles the integration, but I need some help. The
javassist-maven-plugin takes classes from the project class path, passes
them through a transformer and writes new class files. A typical project
setup looks like this:

parent with modules:
  - module a with classes to be transformed
  - module b with transformer and javassist-maven-plugin, destination of
transformed classes, has optional dependency on module a to stop
transitive dependencies
  - module c depends on transformed classes in module b

What I would like the M2E extension to do, is on changed classes in
module a, transform these classes, write them in module b and refresh
those classes, triggering a build in module c. This being my first
extension, I read the introduction on writing extensions and managed to
setup a project in Eclipse, but that's were it ends. All examples I
could find are about generating source from source, not classes from
classes. Is there an existing extension I could use as an example? If
not, what would be a good approach for this plugin? Which M2E classes do
I need to look at?

Best regards,
Emond Papegaaij


_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/m2e-users



Back to the top