m2e lifecycle mapping: delegating plugin execution - eclipse

According to m2e wiki:
m2e matches plugin executions to actions using combination of plugin
groupId, artifactId, version range and goal. There are three basic
actions that m2e can be instructed to do with a plugin execution --
ignore, execute and delegate to a project configurator.
Further I can read that to ignore a plugin I need to do:
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<versionRange>[2.0.5,)</versionRange>
<goals>
<goal>process</goal>
</goals>
</pluginExecutionFilter>
<action>
<delegate />
</action>
</pluginExecution>
So it seems logical that to delegate execution I should do the same but with:
<action>
<delegate />
</action>
But it doesn't work. I'm getting following error:
No enum constant org.eclipse.m2e.core.lifecyclemapping.model.PluginExecutionAction.delegate
So what is the way to delegate plugin execution? Should I just omit pluginExecution element for plugins that I want to delegate?

Regarding to the M2E compatible maven plugins. There are only
1. <ignore/> mapping
2. <execute/> mapping
There is no mentioned tag for delegate.
If I understand correctly, It is a default configuration without any required configuration. It's just let the Eclipse M2E / M2E extension to decide. Please note, for me, I'm using the "m2e project configurators for Eclipse WTP" from JBoss for working with the web project. You may need to use some M2E extension which is matched with your requirement.
I always use the ignore for managing the customized resources and it work correctly.
Update:
At the Eclipse, please click menu Windows ---> preferences --> Maven ---> Discovery. Then click the "Open Catalog" button. The system will give you a list of extension (m2e connector) for installing. For example, there are the Android connector, antlr, AspectJ and so on. I hope that there may be an extension which will help you to achieve the requirement.

Related

Debuggin Vert.x-Maven-Projekt inside Eclipse

I am currently developing an Vert.x Application inside Eclipse with maven. I did the Projekt-Setup like descripted here: http://vertx.io/maven_dev.html
Everything went fine, the project builds succesfully and the server gets started successfully in debug mode via the maven launch configuration with the goal: package vertx:runMod
However, if i set a breakpoint, the debugger stops at the right position and showing me the right stacktrace but it doesnt show me the line inside the source. instead of that it shows the infamous "Source not found"-screen with the "Edit Source Lookup Path"-Button.
The funny thing about this is that this also happens when the breakpoint is inside one of my own java files.
I can also navigate into the source of for example vertx-core-2.0.0-final-sources.jar via STRG-Left click on a vert.x class . After doing this i can see the debug-Infos on Variables ect. via mouse-over as usual. If i double click on the stack again eclipse changes back to the "source not found"-screen-tab again.
I also tried to run the maven goal "clean eclipse:eclipse" on my Project as suggested here: Run Vertx in an IDE with no success.
I also tried all suggestions from here: Eclipse Maven debug - source not found with no success
I think it has something to do with the way the application gets launched. (via vert.x Container-Instance out of maven goal)
Its Eclipse Luna (4.4) with m2e-Plugin vers. 1.5 with maven 3.2.1, and vert.x 2.1
Any Help would be great. THX in advance
At least i found out how to debug into my own source files. I simply had to generate the source.jar for my project when it gets installed via the maven goal. I added the following to my pom under the <plugins> -section
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
After that i linked this generated source-jar-file to my debugger via the "Edit Source Lookup Path"-Button (this has to be done only the first time)
The flaw about this is, if i change a single line in my source files i have to rebuild the whole projekt including the source.jar via maven -install. If i am not doing this the debugger ends up in wrong line numbers.
I also didnt found out how to debug into the classes that are inside my dependency-jars. So at least this isnt solved yet.

m2e cannot run nested instances of Eclipse

I'm using the Tycho eclipserun plugin to generate Java source code for an EMF model during build (as opposed to having the sources checked in). Configuring the plugin to run as part of the maven build works fine, but I would also like to configure m2e so that the same goal is executed when building from inside Eclipse. So, I imagined that could get away with just specifying <execute/> instead of <ignore/> in the lifecycle mapping metadata, like so:
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-eclipserun-plugin</artifactId>
<versionRange>[0.21.0,)</versionRange>
<goals>
<goal>eclipse-run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
But then m2e complains saying
Execution default of goal
org.eclipse.tycho.extras:tycho-eclipserun-plugin:0.21.0:eclipse-run
failed: java.lang.IllegalStateException: Cannot run multiple Equinox
instances in one build. Consider configuring the Tycho build
extension, so that all mojos using Tycho functionality share the same
Equinox runtime.
(org.eclipse.tycho.extras:tycho-eclipserun-plugin:0.21.0:eclipse-run:default:generate-sources)
Ok, so m2e cannot run a nested Equinox instance in the same build, which kind of make sense.
Is there a solution for this? One solution I could imagine would be to execute a standalone Eclipse, but I really like the way the eclipserun plugin allows be to do that just by specifying a remote p2 repo and a bunch of features to include, instead of having to set up a standalone Eclipse more or less manually.
If you are already running in Eclipse, you could execute your EMF generation steps in that runtime directly. So you'd need to configure a builder which does the same steps as the tycho-eclipserun-plugin.
In general, for the case where some build step needs to be executed in Eclipse, but in a different way than in Maven, m2e has the concept of configurators: A configurator could tell m2e what to do when it encounters a certain build plug-in. So in case of the tycho-eclipserun-plugin, the configurator could let the goal run in a forked process instead of in-process. However, I'm not aware of such a m2e configurator, and it remains to decide whether it is really a good idea to fork processes as part of the incremental Eclipse build.

wro4j & m2e Eclipse not compiling LESS

I am trying to setup my developer env so that I can use maven to compile my LESS files for formal builds, but also have Eclipse compile the LESS for incremental builds so I dont have to keep kicking of maven tasks every time I make a LESS change. Having looked around - it seems like wro4j & the maven plugin & the m2e-wtp plugin should provide all that.
My setup is as follows: I have just installed the latest stable Eclipse (Java EE package, that includes the WTP stuff - v4.3) and I have installed the m2e plugin and the m2e-wtp plugins.
pom.xml:
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.4.5</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<targetGroups>roa-all</targetGroups>
<destinationFolder>${project.build.directory}/${project.build.finalName}</destinationFolder>
<cssDestinationFolder>${project.build.directory}/${project.build.finalName}/css/</cssDestinationFolder>
<jsDestinationFolder>${project.build.directory}/${project.build.finalName}/js/</jsDestinationFolder>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
</configuration>
</plugin>
wro.properties:
preProcessors=cssImport,semicolonAppender
postProcessors=lessCss,cssMinJawr
wro.xml:
<groups xmlns="http://www.isdc.ro/wro">
<group name="roa-all">
<css>/less/*.less</css>
</group>
</groups>
Inside my /less/ folder are basically a few css files that I have renamed .less files, and one where I have actually added some LESS syntax with a few colour variables set. This mostly works, as I make changes to my LESS, the plugin detects and rebuilds my uber css file, however, rather critically, it doesn't seem to be compiling the LESS - it combines the files, and minifies, but my #variables are all still in LESS syntax.
I also noticed that the maven plugin was up to v 1.7.0 so tried upgrading to that to see if that was the problem, but that just does nothing at all (nothing gets built at all and I have no uber css etc)
Anyone had any experience setting this up or know anything I have missed in the setup?
The problem was because I had some invalid LESS in one of my files - this basically meant the compile step was failing, so the other LESS files were not being compiled to CSS (which resulted in the LESS variables being output in my file) - With the Eclipse incremental build, this failure was not being reported so I didn't see it.
I discovered it by explicitly running the maven command, and then got the normal maven logs which included details of the compilation failure.
That aside, the eclipse incremental build for LESS is working really nicely since!
As mentioned in the comments above, I wrote up how to set it all up here:
Eclipse & LESS - Better development time with incremental builds

How to undo Mark goal run as ignored in Eclipse build in Eclipse preferences?

I mistakenly clicked the "Mark goal run as ignored in Eclipse build in Eclipse preferences (experimental)":
Where/How do I undo this?
m2e uses a file YOUR_WORKSPACE/.metadata/.plugins/org2.eclipse.m2e.core/lifecycle-mapping-metadata.xml to store the global lifecycle mappings.
You could manually open this file and remove the corresponding entries. After that you should reload the global lifecycle mappings using the 'reload workspace lifecycle mappings metadata' in window > preferences > maven > lifecycle mappings. But you could also edit the file while Eclipse isn't running. In this case you don't have to reload anything.
If you have only added one ignore then you can delete the file completely (maybe make a backup somewhere just to be safe). If you want to remove one but leave the others then take everything between <pluginExecution> and </pluginExecution> for your choice.
I hope this helps a bit. :)
I Know i am answering the question quite late, But i have the issue in the new version and it will be useful for the developer.
Since this plugin configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. Even though if you want to remove the changes then there will be new plugin will be added in the pluginManagement
with below groupID and artifactID
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
With Maven goal as below
<goals>
<goal>generate-application-xml</goal>
</goals>

Problems by import of a multiple modules maven 2 project into eclipse workspace

I was wondering if someone has experienced the same problem as me and can help me.
I have a maven project which contains 6 modules. Some of modules are depending on each other. The project is written in Java and builds to jars, wars and aar. I've been trying to import it to Eclipse with the m2eclipse plug-in. It seems to work fine until the project builds. During the build process I get hundreds of errors complaining about missing Java files which are generated. As I found out eclipse can't recognize that some of generated packages should be interpreted as source code. I don't realy know what to do with it as I spent a lot of time already trying to solve this issue. The project is building fine with command line. My target is to debug the whole project on Tomcat server that's why I want to use eclipse as it has a pretty good integration with Tomcat.
Every help would be greatly appreciated.
Thank you!
As documented in the Why generated source folders are not added to classpath entry of the FAQ:
Maven plugins used to generate source
code from resources or other sources
can register additional source folders
to Maven project during the build.
Usually such plugins are bound to
process-resources (or
process-test-resources) build phase
(for example jaxb, modello or xdoclet
plugins). This means that to get those
source folders for generated sources,
we have to run corresponding Maven
build phase.
Not all projects using generated
sources, so for performance reasons,
m2eclipse does not run any Maven goals
by default on project import. This can
be changed in the Maven settings in
"Window > Preferences... > Maven >
Goals to run on project import" (e.g.
you can specify "process-resources"
build phase or specific plugins in
that field).
Alternatively you can run "Maven >
Update project configuration" action
from the project popup menu, which is
configured to run "process-resources"
by default and it can be also changed
on the same preference page.
So either add the goal to which the source generation process is bound to the list of goals to run on import or generate sources by running maven and update the project configuration.
Try using mvn eclipse:eclipse
Under the project where you have additionally generated source. When this is generated by maven it is normally under target folder.
Therefor eclipse:eclipse will recognize this and add as a source folder.
Rembember to refresh the project after this.
Use build-helper-maven-plugin (sample bellow) to tell Eclipse to add a generated folder to the build path :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/cxf</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Add this in the pom of each project that generates sources...