Discussion:
[m2e-wtp-dev] Improve project configurators execution order
Fred Bricon
2014-10-31 17:49:09 UTC
Permalink
Hi all,

FYI, I opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=449495 which
reads :

Currently, for any given Mojo execution in the Maven Lifecycle, you
can have one "primary" configurator and an unlimited number of
"secondary" configurators, that would run in an undefined order, after
the primary one.

And BTW, having 2 "primary" configurators is forbidden : eg. for the
maven-war-plugin:war goal, m2e-wtp and m2eclipse-webby provide
competing "primary" configurators that m2e will reject.

In m2e-wtp, I intend to drop the current, legacy
org.maven.ide.eclipse.configuration.wtp configurator that basically
handles all javaee types (war, ejb, ear...) and replace it with
specialized, public configurators for each type. That will allow 3rd
party plugins to reuse and extend them more easily (See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=412213).

But in order to keep backward compatibility with existing plugins
depending on it, (I know of JBoss Tools and the Google Plugin for
Eclipse), I want to keep org.maven.ide.eclipse.configuration.wtp for a
little longer. So I need to be able to chain configurator execution in
a more precise way, eg : org.eclipse.m2e.javaee.web.configurator ->
org.maven.ide.eclipse.configuration.wtp.configurator (empty
configurator) ->
com.google.gdt.eclipse.maven.googleProjectConfigurator

My plan is to be able to perform a topological sort of a Directed
Acyclic Graph (DAG) of project configurators, similar to what we
currently use for Project converters.

Introducing 2 new attributes to the
org.eclipse.m2e.core.projectConfigurators extension point :
- runsAfter : a comma-separated list of configuratorIds a given
configurator should run after. ids suffixed with an exclamation mark
would be optional.
- runsBefore : a comma-separated list of configuratorIds a given
configurator should run before. ids suffixed with a star would be
required

So for instance :

runsAfter="A,B?" means this configurator X needs to run after A. If A
is missing, X will be ignored. If B is present, X will run after. If B
is missing we don't care and execute X anyway (For instance the seam
configurator needs to run after the web project one for wars or the
ear project one for ears, but both are never found at the same time
for a given Mojo execution)

runsBefore="C,D*" means this configurator X needs to before C, *if*
it's present. In this case D *must* be present, or else X will be
ignored.

Obviously, cyclic dependencies are forbidden and will result in an error.

We can still check only 1 "primary" configurator is declared per
MojoExecution, by checking only one configurator has no parent in the
DAG.

The changes required to implement this new feature are fairly self
contained in LifecycleMappingFactory, the projectConfigurators.exsd
schema and a new sorter class.

Existing "secondaryTo" attribute will still be supported for now, but
deprecated. All existing plugins will still work as-is. Only the
plugins requiring to leverage the new sorting feature will require a
dependency to m2e 1.6.

Ideally, I would like to be able to sort configurators not only per
mojoexecution, but rather per project, see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=348791, but that will
require a whole lot of work I'm not sure I can do right now. But this
is a first step in that direction.

Gerrit patch will follow


If you're interested in the discussion, please follow up in Bugzilla.

Fred Bricon
--
"Have you tried turning it off and on again" - The IT Crowd
Loading...