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

I've changed the maven plugin to use BuildContext, but Eclipse is still having issues. It no longer triggers an endless build (even with runOnIncremental), but Eclipse does not see the generated classes. The transformed class files are visible in target/classes in Eclipse, but the modules depending on them do not see them. Also, 'Open type' does not show them. Did I miss anything? I do use buildContext.newFileOutputStream to generate the files.

 

Best regards,

Emond Papegaaij

 

On Saturday 18 January 2014 22:18:19 you wrote:

> You are right, both the transformer and the transformed classes are in the

> same project, but that can be changed. The buildcontext approach seems the

> easiest for now. If I understand it correctly, I only have to improve the

> plugin to support incremental builds and use execute mapping in m2e. Even

> if it does not work, I've at least improved the plugin :). I'll give it a

> try next week. Thanks for the help.

>

> Best regards,

> Emond Papegaaij

>

> On Sat, Jan 18, 2014 at 5:34 PM, Igor Fedorenko <igor@xxxxxxxxxxxxxx> wrote:

> > 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

> >>

> >> _______________________________________________

> >

> > m2e-users mailing list

> > m2e-users@xxxxxxxxxxx

> > https://dev.eclipse.org/mailman/listinfo/m2e-users

 


Back to the top