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 Igor

Thanks for your response. I've learned something from Adrien, and
something from you. Cool.
More inline.

Grzegorz

On 2014-02-17 18:40, Igor Fedorenko wrote:
>
>
> On 2/17/2014, 11:24, Grzegorz Słowikowski 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
>> ?
>
> How do you inject BuildContext instance in your mojo? Using plugin-tools
> @Component, plexus @Requirement or jsr330 @Inject all should inject
> instance of EclipseBuildContext inside m2e.
    @org.apache.maven.plugins.annotations.Component
    private BuildContext buildContext;

>
>> 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)?
>
> During project import and configuration update m2e needs to configure
> workspace project sources and resources folders. To do this, m2e runs
> maven build with empty resource delta and expects mojos do not produce
> any outputs.
And it it produces any output, like in my case now, because I don't use
BuildContext
in recently released version yet?
I have two mojos in my lifecycle-mapping-metadata.xml:
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
They are similar. They unpack some dependencies' contents and add some
of its folders
as new source roots. If during project import there is empty delta, my
mojos still need to be executed
Actually they are not executed on incremental builds, only on full
builds (import and Maven update, right?).

> If your mojo does not properly use BuildContext API it will
> do more work than necessary, will create filesystem resources that may
> confuse other Eclipse workspace builders.
If mojo does more work, I don't worry, it can be improved later. What
worries me is
how can it confuse other builders. I would like to be able to test it,
and see the situations
when it does not work properly to be able to better understand and fix it.

> Mojo execution may actually
> fail if it depends on outputs of other mojo executions.
>
> During workspace build mojo needs to check if its inputs have changed.
> Eclipse runs build on every workspace file modification, so if the mojo
> generates its outputs unconditionally, this will trigger new build,
> which will result in unconditional generation of mojo outputs and so on.
>
> Calling "refresh" also makes mojo outputs visible to eclipse workspace
> and other builders. Eclipse java compiler, for example, will not see
> sources generated by the mojo if they are not refreshed in the workspace.
OK, I think what I need most now is knowledge, how to debug all this.
I'm quite experienced Maven developer (from Maven plugin author point of
view),
but completely new to Eclipse development. Give me some documentation links,
please. I don't know, if I need to learn all, maybe only about things I
need to
test/debug my plugin BuildContext usage.
> -- 
> Regards,
> Igor
>
>
>
>> 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
>>
> _______________________________________________
> m2e-users mailing list
> m2e-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/m2e-users



Back to the top