Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] Maven plugin and calling buildContext.refresh(File)

Hi Adrien

Thanks for your response. More questions below.

Grzegorz

On 2014-02-17 17:48, Adrien Rivard wrote:
Hi,


On Mon, Feb 17, 2014 at 5:24 PM, Grzegorz Słowikowski <gslowikowski@xxxxxxxxx> wrote:
Hi All

I have Maven plugin defining custom "play" packaging (for Play!
Framework 1.x http://www.playframework.com/) applications.
In latest release I added M2Eclipse integration
(see
http://maven-play-plugin.googlecode.com/svn/tags/plugin-1.0.0-beta7/play-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml)
I've read about BuildContext usage here:
https://wiki.eclipse.org/M2E_compatible_maven_plugins , but I have some
questions related to this functionality.

1. I wanted to test/debug "buildContext.refresh( someFile )" so I ran
Maven builds inside Eclipse, but I've always had the default
"org.sonatype.plexus.build.incremental.DefaultBuildContext"
implementation when I've debugged my code.
What should I do to get M2Eclipse implementation of BuildContext interface:
org.eclipse.m2e.core.internal.builder.EclipseBuildContext
org.eclipse.m2e.core.internal.builder.EclipseIncrementalBuildContext
?

You want to debug Eclipse itself and not Maven. (If you run with "Run as Maven..." menu, this will not work, this is nearly just like a console maven build , just use project> clean or trigger incremental build)
I used embedded Maven instance and thought it's "instrumented" somehow by Eclipse.
I usually launch a second eclipse instance from within the first to do that.
How to do it? If I will do it, where will my Maven logs go?
 
Look for tutorials on developping Eclipse plugins if you do not know how to do that.
Can you give me any links?



2. Sources and resources are processed by M2E completely differently. Is
calling "refresh" important for sources, resources or both, and why
(why not calling "refresh()" can lead to infinite rebuilds)?


AFAIK, modifications will either not be seen by Eclipse, or if you have automatic refresh of workspace, it will loop ( auto-refresh> found one external modif>rebuild> auto-refresh > found one external modif >... ).
Does this mean that with automatic build turned off (I never use it) it is not that simple to see this problem?


Calling refresh() will inform Eclipse that the modification is part of the current build and not an external one.
You need to call refresh() for all modifications. (or  via  buildContext.newFileOutputStream).
OK, next question. In my plugin I unzip some dependency content to disk, and add it's subdirectory as new source root.
When I do it for the first time (unzip to empty folder, no overwrite) Is is better to call refresh once for the whole subdirectory
added as source root or for every file?

Here is good example https://maven-play-plugin.googlecode.com/svn/tags/test-projects-1.0.0-beta7/packagings/default/with-crud-module/play-1.2.x
When importing to Eclipse, you have to set "autodeps" profile. "play-crud" zip-type dependency content will be unpacked to "${basedir}/modules/crud-1.2.7"
directory by play:dependencies mojo and "${basedir}/modules/crud-1.2.7/app" will be added as new source root by play:initialize mojo.
Should I call "buildContext.refresh(new File(basedir, "modules/crud-1.2.7/app")) or for every file inside "modules/crud-1.2.7/app"?



I have some more questions, but I would like to receive responses for
the above two first. Thank you in advance.

Regards

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



--
Adrien Rivard


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


Back to the top