Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-dev] Plugin development help : generate-sources and add to classpath

Are you sure the plugin execution isn't mapped to something else
already, either at workspace or project level? This overrides any
mapping configuration provided by m2e extension. You can see if that's
the case by right-clicking on the project, Maven, Lifecycle Mapping.

Also, make sure your m2e extension provides
lifecycle-mapping-metadata.xml and corresponding
lifecycleMappingMetadataSource extension in plugin.xml. See [1] for more
details

As for writing m2e extension or not. I generally recommend using
BuildContext API as explained in [2]. This is far more user friendly and
easier to maintain in my experience, but does requires changes to the
Maven plugin itself. Also, we are about to launch early adopter
problem for the next generation of this API. In addition to m2e
integration the new version will also provide incremental build support
for Maven on command line, which can be significant benefit for
some/many plugins. If you are interested to participate, please email me
directly.


[1] https://wiki.eclipse.org/M2E_Extension_Development
[2] https://wiki.eclipse.org/M2E_compatible_maven_plugins

--
Regards,
Igor

On 2/3/2014, 11:43, Anthony Dahanne wrote:
Hello m2e users and devs,
The other day I was importing a hudson plugin source code into Eclipse
(Kepler service release 1, build id 20130919-0819 , m2e
1.4.0.20130601-0317), and I noticed that I had to first
* invoke mvn generate-sources (from Eclipse using m2e, that worked fine)
* right click on target/generate-sources/localizer and choose "Build
path -> Use as source folder.."
so that it compiles fine...
In fact, it's just that for i18n, there's this maven plugin :

         <plugin>

           <groupId>org.jvnet.localizer</groupId>

           <artifactId>maven-localizer-plugin</artifactId>

           <version>1.14</version>

         </plugin>

that binds a goal named "generate" to "generate-sources" that will
process resources named Message*.properties in the resources, to
generate classes with the same name.

Since m2e does not seem to "magically" run that phase and add the
generated sources to the classpath, I started creating a plugin for that.

But my plugin is ignored by m2e...

Here are its 2 classes and plugin.xml and lifecycle-mapping-metadata.xml :

https://gist.github.com/anthonydahanne/8787256

m2e does not do anything about this plugin, it just ignores it , see the
log when I do Maven->Update project on a Hudson plugin :

11:39:48.507 [Worker-8] DEBUG o.e.m.c.i.builder.MavenBuilder - Building
project build-timeout

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Build participants
for MavenProject: org.jenkins-ci.plugins:build-timeout:1.11-SNAPSHOT @
/Users/anthony/workspaces/jenkins/build-timeout-plugin/pom.xml

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Mojo execution key:
org.jenkins-ci.tools:maven-hpi-plugin:1.90:validate (execution:
default-validate, phase: validate)

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Action: execute

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Mojo execution key:
org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce (execution:
enforce-maven, phase: validate)

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Action: ignore

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Mojo execution key:
org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:display-info
(execution: display-info, phase: validate)

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Action: ignore

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Mojo execution key:
org.jvnet.localizer:maven-localizer-plugin:1.14:generate (execution:
default, phase: generate-sources)

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Action: execute

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Mojo execution key:
org.codehaus.mojo:antlr-maven-plugin:2.1:generate (execution: default,
phase: generate-sources)

11:39:48.518 [Worker-8] DEBUG
o.e.m.c.p.c.AbstractCustomizableLifecycleMapping - Action: execute


So here is my question :

* do I even need to create a plugin for that ?

* if so, why did I do wrong in the plugin code / binding ?


Thanks a lot in advance for your answers !

Anthony






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



Back to the top