[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [m2e-dev] Extension changing runtime environment
|
Baking toolchains support into m2e is another option, I think, since
there is tight integration between maven-compiler-plugin and toolchains
during command line build. I can offer timely and fair review, if
somebody contributes a quality patch.
--
Regards,
Igor
On 2015-01-16 10:21, Fred Bricon wrote:
Have you tried declaring your configurator as secondaryTo
the javaConfigurator?
<extension point="org.eclipse.m2e.core.projectConfigurators">
<configurator
id="foo.bar.toolchain"
class="foo.bar.toolchainConfigurator"
name="toolchainConfigurator"
secondaryTo="org.eclipse.m2e.jdt.javaConfigurator"
/>
</extension>
Keeping the same goal mappings as javaConfigurator in your lifecycle
mapping file.
So the JDT one will run first, then your extension can override the
original settings
On Fri, Jan 16, 2015 at 4:34 AM, Martin Frydl <mfrydl@xxxxxxxxx
<mailto:mfrydl@xxxxxxxxx>> wrote:
Hello,
I'm trying to write extension to m2e which will change execution
environment. Currently it is selected according to target JRE
version set in maven-compiler-plugin
(org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.getExecutionEnvironmentId()).
I want to do that according to maven-toolchains-plugin.
I've created my own configurator extending
AbstractJavaProjectConfigurator, overridden
getExecutionEnvironmentId() method and registered it to
maven-toolchains-plugin. Now when I update project in Eclipse, my
configurator is correctly invoked and selects the right environment.
However, in next step the original JavaProjectConfigurator
registered to maven-compiler-plugin is run and it resets execution
environment back according to target.
How can I provide m2e plugin which will change behavior of the
JavaProjectConfigurator? Since it has lot of protected methods, it
looks like being extensible, but I'm not able to properly register
my extension. When I register my configurator to
maven-toolchains-plugin, it runs before JavaProjectConfigurator and
any changes are lost. If I register my configurator also to
maven-compiler-plugin in hope to override the default, it does not
work at all since there are two configurators for single maven
plugin which is not allowed. Looking at bug #435803
<https://bugs.eclipse.org/bugs/show_bug.cgi?id=435803>, it should be
somehow possible to provide extensions/subclasses to
JavaProjectConfigurator, but I'm not able to find any information
how that should be achieved. The examples I've found only generate
extra sources files, but don't alter the project settings.
So far I see only two "ugly" solutions. First, modify
AbstractJavaProjectConfigurator directly in org.eclipse.m2e.jdt
plugin, which means I cannot use "official" m2e plugin any more.
Second possibility is to add extra useless binding of
maven-toolchains-plugin to my pom files since when I bind it to some
phase after maven-compiler-plugin, my m2e plugin gets invoked after
JavaProjectConfigurator and then it works since nobody will
overwrite my changes. Normally the toolchains plugin is bound to
some early phase like "initialize" because it needs to be run before
compilation. Later phases are too late. But binding it also to
"test" phase puts it twice in maven execution (before and after
compiler) and that forces m2e to run configurators in different order.
How to create m2e plugin changing execution environment "the right way"?
Regards,
Martin Frydl
_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx <mailto:m2e-dev@xxxxxxxxxxx>
To change your delivery options, retrieve your password, or
unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/m2e-dev
--
"Have you tried turning it off and on again" - The IT Crowd
_______________________________________________
m2e-dev mailing list
m2e-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/m2e-dev