Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] Scanning for modified resources (BuildContext vs other means)

Thanks for the very informative clarification, Igor!

And yes, I would absolutely be interested in becoming an early adopter of the new version of the BuildContext API.

/Anders


On Fri, Mar 7, 2014 at 2:28 PM, Igor Fedorenko <igor@xxxxxxxxxxxxxx> wrote:


On 2014-03-07, 7:42, Anders Hammar wrote:
According to [1], it says that a maven plugin "MUST use BuildContext to
skip execution when there none of relevant workspace resources changed".

Is it required to use BuildContext, or can I use some other means to
determine if the plugin should skip execution? I'm asking as several
plugin already has a similar functionality through a stale file. I
appreciate that it might not be 100% the same, but close enough IMHO.

So, bottom line, it the requirement to skip execution when there hasn't
been any relevant resource changes or is the requirement to use
BuildContext to determine that?


tl;dr yes, correct mojo implementation requires use of BuildContext

All this applies to mojos that modify filesystem, i.e. create, modify or
delete files. Mojos that only modify MavenProject state should be safe
to run without any checks and m2e is expected to maintain consistent
MavenProject.

For mojos that do modify filesystem need to be aware of there build types

* Configuration build is performed during project import and
configuration update. Mojos are not expected to do any resource
processing during configuration build and Eclipse/m2e use empty
BuildContext to make mojos skip execution. Project is not fully setup at
this point and mojo execution is likely to fail, because dependency
classes are not available yet, for example. Even if execution does not
fail, it will unnecessary slow down project import and configuration update.

* Full build is performed when user selects "Project/Clean..." action
and BuildContext provided by m2e will list all resources as modified.

* Incremental build is performed on each workspace resource
modification. To avoid endless workspace builds it is absolutely
essential to to skip mojo execution if there are no relevant changes.
Mojo execution may use other means to do that, I suppose, but you I'd
still use BuildContext to make it easier to reason about mojo
implementation.

Btw, we are working on new version of BuildContext API that will provide
proper incremental build behaviour during command line build too, so
mojos will not need to implement custom stale file detection logic
(which is pretty tricky to implement correctly). I may be able to give
you access to the code if you are interested to become an early adopter.


--
Regards,
Igor

/Anders

[1] http://wiki.eclipse.org/M2E_compatible_maven_plugins

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


Back to the top