Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] m2e plugin execution enhances classes but eclipse resources are then out of sync

No, m2e only refreshes resources that were explicitly marked for refresh
via BuildContext API. Refreshing everything is too expansive and, more
importantly, will result in an endless build loop in some scenarios.
You will have to implement an m2e project configurator to do this, if
you think this is a reasonable solution for openjpa.

Also, I am not sure what JDT is going to do with modified .class files.
I believe the officially supported way to manipulate .class files is by
implementing compilationParticipant o.e.jdt.core extension point.

--
Regards,
Igor

On 12-01-25 12:34 AM, Anthony Fryer wrote:
I just updated to version 1.1.0.20120111-2043 to see if anything had
changed that might fix the issue. I still have the problem but had an
idea about how it might be solved. I notice the eclipse project
properties->Maven property now has a "Lifecycle Mapping (experimental)"
page which is great. For my JPA project, If i check "show lifecycle
phases" i can see openjpa:enhance with a mapping value of "execute" for
the "process-classes" phase.

The problem i have is openjpa:enhance will modify the class files which
will then be out of sync with the eclipse workspace. Refreshing the
target folder updates the classes in eclipse but this also triggers
another incremental build if "Build Automatically" is enabled so the
classes are immediately out of sync again. Classes out of sync is an
issue if I have a server configured because i can't publish to the
server unless all classes are in sync.

Can the m2e Maven Builder automatically refresh the classes in the
eclipse workspace if it detects that a Plugin Execution will occur in
the "process-classes" phase? This refreshing of the classes would have
to be done after the "process-classes" phase is complete and in a way
that wouldn't trigger another eclipse incremental build.



 > > > Date: Wed, 7 Dec 2011 22:09:51 -0500
 > > > From: igor@xxxxxxxxxxxxxx
 > > > To: m2e-users@xxxxxxxxxxx
 > > > Subject: Re: [m2e-users] m2e plugin execution enhances classes but
 > > eclipse resources are then out of sync
 > > >
 > > > If you are interested in providing a patch that implements this idea,
 > > > please join m2e-dev@xxxxxxxxxxx and I'll give you some pointers
where to
 > > > start and explain basic requirements to the patches we can accept.
 > > >
 > > > --
 > > > Regards,
 > > > Igor
 > > >
 > > > On 11-12-07 9:16 PM, Anthony Fryer wrote:
 > > > > It would be nice if you could configure the lifecycle-mappnig
to tell
 > > > > the m2e MavenBuilder that the classes have been modified by a
plugin
 > > > > execution and that it should refresh the class resources in eclipse
 > > > > without triggering a new incremental build.
 > > > >
 > > > > Something like this...
 > > > >
 > > > > <action>
 > > > > <execute>
 > > > > <modifiesClassFiles>true</modifiesClassFiles>
 > > > > </execute>
 > > > > </action>
 > > > >
 > > > > I'm just thinkg that might remove the need to create an m2e
 > > extension to
 > > > > get this to work.
 > > > >
 > > > > Cheers,
 > > > >
 > > > > Anthony
 > > > >
 > > > > > Date: Wed, 7 Dec 2011 07:30:08 -0500
 > > > > > From: igor@xxxxxxxxxxxxxx
 > > > > > To: m2e-users@xxxxxxxxxxx
 > > > > > Subject: Re: [m2e-users] m2e plugin execution enhances
classes but
 > > > > eclipse resources are then out of sync
 > > > > >
 > > > > > This is exactly the problem described in [1]. Here is a relevant
 > > quote:
 > > > > >
 > > > > > "Out-of-workspace resource changes made by Maven plugin triggered
 > > > > > unexpected workspace builds. This was very indeterministic.
In some
 > > > > > cases projects appeared to work fine. In some cases,
 > > generated/filtered
 > > > > > resources would go missing. And in some cases workspace build
 > > would go
 > > > > > on forever."
 > > > > >
 > > > > > You need a proper m2e integration to modify .class files,
<execute/>
 > > > > > mapping will not work.
 > > > > >
 > > > > > [1] http://wiki.eclipse.org/M2E_plugin_execution_not_covered
 > > > > >
 > > > > > --
 > > > > > Regards,
 > > > > > Igor
 > > > > >
 > > > > > On 11-12-07 6:51 AM, Anthony Fryer wrote:
 > > > > > > I have a JPA project and as part of my maven build I am
 > > enhancing the
 > > > > > > classes. In eclipse have auto build enabled and in my pom.xml I
 > > have
 > > > > > > configured m2e to execute the ehance goal to run as part of the
 > > build.
 > > > > > > This all seems to work fine except for one issue. After the
 > > > > enhancer has
 > > > > > > run, the class files are out of sync with eclipse. This is a
 > > problem
 > > > > > > because if i try to publish to a server I get an error like
 > > > > "Resource is
 > > > > > > out of sync with the file system:
 > > > > > > '/my-project/target/classes/com/xyz/entity/MyEntity.class'.". I
 > > can't
 > > > > > > seem to manually refresh the classes either, so I'm stuck
at this
 > > > > point,
 > > > > > > not being able to publish to the server.
 > > > > > >
 > > > > > > If i configure eclipse to auto Refresh resources automatically
 > > > > > > (windows->preferences->General->Workspace->(Refresh using
 > > native hooks
 > > > > > > or polling | Refresh on Access) ), then i get into a never
 > > ending build
 > > > > > > cycle loop. It builds, runs the enhancer which updates the
 > > class files,
 > > > > > > reloads the class files which triggers another auto build, and
 > > so on,
 > > > > > > building forever.
 > > > > > >
 > > > > > > Could the m2e plugin update the eclipse resources after the
maven
 > > > > > > builder has executed, so that eclipse is then in sync with the
 > > class
 > > > > > > files that could potentially get modified by the maven builder?
 > > > > > >
 > > > > > > The relevent sections of the pom.xml for my project are as
 > > follows...
 > > > > > >
 > > > > > > <plugin>
 > > > > > > <groupId>org.codehaus.mojo</groupId>
 > > > > > > <artifactId>openjpa-maven-plugin</artifactId>
 > > > > > > <version>1.2</version>
 > > > > > > <configuration>
 > > > > > > <includes>**/entity/*.class</includes>
 > > > > > > <excludes>**/entity/*_.class,**/entity/*$*.class</excludes>
 > > > > > > </configuration>
 > > > > > > <executions>
 > > > > > > <execution>
 > > > > > > <id>enhancer</id>
 > > > > > > <phase>process-classes</phase>
 > > > > > > <goals>
 > > > > > > <goal>enhance</goal>
 > > > > > > </goals>
 > > > > > > </execution>
 > > > > > > </executions>
 > > > > > > </plugin>
 > > > > > >
 > > > > > > <pluginManagement>
 > > > > > > <plugins>
 > > > > > > <!--This plugin's configuration is used to store Eclipse m2e
 > > settings
 > > > > > > only. It has no influence on the Maven build itself.-->
 > > > > > > <plugin>
 > > > > > > <groupId>org.eclipse.m2e</groupId>
 > > > > > > <artifactId>lifecycle-mapping</artifactId>
 > > > > > > <version>1.0.0</version>
 > > > > > > <configuration>
 > > > > > > <lifecycleMappingMetadata>
 > > > > > > <pluginExecutions>
 > > > > > > <pluginExecution>
 > > > > > > <pluginExecutionFilter>
 > > > > > > <groupId>org.codehaus.mojo</groupId>
 > > > > > > <artifactId>
 > > > > > > openjpa-maven-plugin
 > > > > > > </artifactId>
 > > > > > > <versionRange>[1.2,)</versionRange>
 > > > > > > <goals>
 > > > > > > <goal>enhance</goal>
 > > > > > > </goals>
 > > > > > > </pluginExecutionFilter>
 > > > > > > <action>
 > > > > > > <execute/>
 > > > > > > </action>
 > > > > > > </pluginExecution>
 > > > > > > </pluginExecutions>
 > > > > > > </lifecycleMappingMetadata>
 > > > > > > </configuration>
 > > > > > > </plugin>
 > > > > > > </plugins>
 > > > > > > </pluginManagement>
 > > > > > >
 > > > > > >
 > > > > > > _______________________________________________
 > > > > > > 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
 > > > >
 > > > >
 > > > > _______________________________________________
 > > > > 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
 > >
 > >
 > > _______________________________________________
 > > m2e-dev mailing list
 > > m2e-dev@xxxxxxxxxxx
 > > https://dev.eclipse.org/mailman/listinfo/m2e-dev
 > _______________________________________________
 > m2e-dev mailing list
 > m2e-dev@xxxxxxxxxxx
 > https://dev.eclipse.org/mailman/listinfo/m2e-dev


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


Back to the top