I've managed to create a very small showcase of the problem (
https://github.com/papegaaij/maven-javassist-demo ). It has 4 modules
with 3 classes in total:
base-classes: nl.topicus.HelloWorld with a perform method that throws
UnsupportedOperationException
transformer: nl.topicus.DemoTransformer replaces the perform method with
a real 'Hello world!'
transformed-classes: destination of the transformed HelloWorld
demo: nl.topicus.Demo invokes HelloWorld.perform
mvn compile works fine on the commandline and mvn exec:java in demo
shows 'Hello world!'. In Eclipse, Demo.java does not compile, and
running it gives "Unresolved compilation problem: HelloWorld cannot be
resolved to a type". In the project explorer (after unhiding output
folders), I can see the correctly transformed HelloWorld class and it
should be on the classpath. I really don't understand why Eclipse does
not pick it up as a type in Demo.java.
I would really appreciate it if you could take a look at it. The plugin
itself is available at https://github.com/papegaaij/maven-javassist .
The current version (1.1-SNAPSHOT) is not yet released to maven central,
so you need to install it in your local repo. Perhaps you can see what's
going wrong, because I'm at a loss.
Best regards,
Emond Papegaaij
On Mon, Jan 20, 2014 at 4:48 PM, Emond Papegaaij
<emond.papegaaij@xxxxxxxxxx <mailto:emond.papegaaij@xxxxxxxxxx>> wrote:
__
It proves to be very difficult to test all this in the project I'm
using it in, mainly due to the size of the project. I'll setup a
smaller demo-project to see why it is not working as intented.
Best regards,
Emond Papegaaij
On Monday 20 January 2014 09:27:22 Igor Fedorenko wrote:
> Eclipse does not require sources to be present.
>
> --
> Regards,
> Igor
>
> On 1/20/2014, 9:21, Emond Papegaaij wrote:
> > The consuming module only has the transformed classes on the
classpath.
> > The module with transformed classes does have the original
classes on
> > the classpath using an optional dependency. However, it does
not seem to
> > be a conflict between classes on the classpath. I tried
generating an
> > additional class (one that does not exist in the original
classes), and
> > this class is also not picked up. It seems Eclipse does not see
classes
> > in workspace modules when there is no source for those classes.
Could
> > this be the case?
> >
> > Best regards,
> >
> > Emond Papegaaij
> >
> > On Monday 20 January 2014 09:09:57 Igor Fedorenko wrote:
> > > What does classpath of the consuming project look like? Does
it include
> > >
> > > both original classes and generated ones?
> > >
> > >
> > >
> > > Generally, I recommend against split packages (using OSGi
terminology),
> > >
> > > especially if you have exact the same classnames in different
modules.
> > >
> > >
> > >
> > > --
> > >
> > > Regards,
> > >
> > > Igor
> > >
> > > On 1/20/2014, 8:50, Emond Papegaaij wrote:
> > > > We are generating new class files, based on existing class
files. For
> > > >
> > > > example, if module a contains 'com.mycompany.Foo', we are
generaing
> > > >
> > > > 'com.mycompany.Foo' in module b based on the class in module a.
> >
> > It's the
> >
> > > > same classname, but different bytecode. The files do
contain the
> > > > right
> > > >
> > > > contents on the file system (verified with javap).
> > > >
> > > >
> > > >
> > > > With "Eclipse does not see the generated classes", I mean that
> > > > classes
> > > >
> > > > using these classes have compile errors, type completion
does not
> > > > work,
> > > >
> > > > 'Open type' does not work. I can see the files in the project
> > > > explorer
> > > >
> > > > (in target/classes), but Eclipse does not seem to know
about the
> > > > types.
> > > >
> > > >
> > > >
> > > > The Maven Workspace Build view lists all classes produced
by the
> >
> > plugin,
> >
> > > > so it seems BuildContext is working fine.
> > > >
> > > >
> > > >
> > > > Best regards,
> > > >
> > > >
> > > >
> > > > Emond Papegaaij
> > > >
> > > > On Monday 20 January 2014 07:57:34 Igor Fedorenko wrote:
> > > > > Are you generating new class files or changing existing class
> > > > > files?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Can you explain what "Eclipse does not see the generated
classes"
> > > > >
> > > > > means?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Can you check if class file contents is as expected on
filesystem?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > You may also want to check Maven Workspace Build view,
which should
> > > > >
> > > > > show
> > > > >
> > > > >
> > > > >
> > > > > if your mojo is executed, what input files it gets and
what output
> > > > >
> > > > > files
> > > > >
> > > > >
> > > > >
> > > > > it produces throw BuildContext API. (note that the view is
> >
> > "paused" by
> >
> > > > > default, you need to click pause button to enable recording).
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > >
> > > > >
> > > > >
> > > > > Regards,
> > > > >
> > > > >
> > > > >
> > > > > Igor
> > > > >
> > > > > On 1/20/2014, 7:32, Emond Papegaaij wrote:
> > > > > > 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 <mailto: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 <mailto:m2e-users@xxxxxxxxxxx>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> https://dev.eclipse.org/mailman/listinfo/m2e-users
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> _______________________________________________
> > > > > > > >
> > > > > > > > m2e-users mailing list
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > https://dev.eclipse.org/mailman/listinfo/m2e-users
> > > > > >
> > > > > > _______________________________________________
> > > > > >
> > > > > >
> > > > > >
> > > > > > m2e-users mailing list
> > > > > >
> > > > > >
> > > > > >
> > > > > > m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> > > > > >
> > > > > >
> > > > > >
> > > > > > https://dev.eclipse.org/mailman/listinfo/m2e-users
> > > > >
> > > > > _______________________________________________
> > > > >
> > > > >
> > > > >
> > > > > m2e-users mailing list
> > > > >
> > > > >
> > > > >
> > > > > m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> > > > >
> > > > >
> > > > >
> > > > > https://dev.eclipse.org/mailman/listinfo/m2e-users
> > > >
> > > > _______________________________________________
> > > >
> > > > m2e-users mailing list
> > > >
> > > > m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> > > >
> > > > https://dev.eclipse.org/mailman/listinfo/m2e-users
> > >
> > > _______________________________________________
> > >
> > > m2e-users mailing list
> > >
> > > m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> > >
> > > https://dev.eclipse.org/mailman/listinfo/m2e-users
> >
> > _______________________________________________
> > m2e-users mailing list
> > m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> > https://dev.eclipse.org/mailman/listinfo/m2e-users
>
> _______________________________________________
> m2e-users mailing list
> m2e-users@xxxxxxxxxxx <mailto:m2e-users@xxxxxxxxxxx>
> https://dev.eclipse.org/mailman/listinfo/m2e-users
_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx <mailto: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