Cannot compile due to M2Eclipse which doesn't find connector - maven

There is a section in the pom.xml file that requires the Maven-Replacer-Plugin and (I believe) GitDescribe.
Here are the errors it gives me:
Plugin execution not covered by lifecycle configuration: com.lukegb.mojo:gitdescribe-maven-plugin:1.3:gitdescribe (execution: default, phase: compile)
Plugin execution not covered by lifecycle configuration: com.google.code.maven-replacer-plugin:maven-replacer-plugin:1.3.8:replace (execution: default, phase: generate-resources)

This message comes up because m2e doesn't know what to do at this phase. The build should work with command line maven, but m2e wants you to specify whether you want it to run the plugin or not.
The fix depends on what you want to happen. You can either have eclipse ignore the plugin or execute it as part of the build.
The documentation explains it in further detail here, but I'm copying the easy answer below.
https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
This changes the pom to add some eclipse metadata. If you're just trying to get it to build this will work.
HINT: Use quick fix to create “ignore” mapping, then replace
action with . M2Eclipse 1.3 and newer assume safer
runOnIncremental=false by default. It is recommended to always
specific desired runOnIncremental value explicitly in lifecycle
mapping configuration.
You can also change your preferences in newer eclipse/m2e versions. It's the other quick fix option. You can change this one under Project Properties->Maven->Lifecycle Mapping.

This error was well described in their documentation.
This feature was added in M2Eclipse 1.0 (now m2e).
It caused much trouble, like reported in this blog post.
One solution was to pollute the pom.xml with data about the plugin lifecycle mapping metadata, but it was not very satisfying.
In m2e 1.1, plugin developers could embed a file named lifecycle-mapping-metadata.xml in their plugins to make it work in Eclipse (see M2E compatible maven plugins).
Fortunately, since m2e 1.2, things have evolved and we can now configure it in Eclipse Preferences (see Eclipse workspace lifecycle mapping metadata).

Related

How to use maven artifact in the development of Eclipse plugin via Tycho

Since version 2.2.0 Tycho has introduced a new feature to allow using maven artifacts in PDE target platforms, and here's the how-to. Following its instructions I have included an artifact of Saxon-HE into my target platform. I can see the wrapped OSGi bundle of Saxon after ticking the Show Location Content option in the Target Definition Editor. Also I ran mvn clean verify command to make sure that the artifact is downloaded into my computer. However,
as I began to try to import the package into my Eclipse plugin code, I found no suggestions from this package.
When I tried to include the package as a feature in the Product Editor, I couldn't find any option.
In addition, when attempting to include it as required plugin / imported packages in the Plugin Editor, there was no option, too.
What's more, the product produced by mvn clean verify did not contain such plugin as Saxon-HE after checking my whole RCP project.
All the efforts in vain above made me wonder how I can use a maven artifact in my plugin development. I desperately need the functionalities Saxon-HE provides with to enhance my plugin. Anyone experienced sharing your expertise?
-- 2021.08.13 update --
Manually I included this plugin in the plugin list of my RCP project via source file editing. Its jar file appeared in the plugin folder of the product. But anyway I was not able to validate the availability of the library in the dependency tab of the plugin manifest editor as shown in Vogella's tutorial. Restarting the IDE did not help, either. This might mean that I have to manually code the source code without the content assistance.

Gradle equivalent for Maven Java formatter that uses com.googlecode.maven-java-formatter-plugin

I'm switching a large project from Maven to Gradle. Existing Maven project uses com.googlecode.maven-java-formatter-plugin to format the Java code. Looked for the equivalent in Gradle. Found https://plugins.gradle.org/plugin/com.github.sherter.google-java-format, but it spewed a bunch of errors out, was really slow, and didn't generate the same output as the Maven plugin.
Also looked here: https://github.com/google/google-java-format - no help.
Is there a Gradle plugin which will give me same result as the Maven plugin?
There is this other Gradle plugin, which uses the Eclipse formatter. Maybe you can tweak it to achieve the same results as with the maven plugin you mentioned (I'm not using this plugin myself).
Note that it is an explicit non-goal of google-java-format and the corresponding Gradle plugin to be configurable. If you are not happy with the formatting style then this tool is probably not appropriate for you.
(if you have technical problems with my Gradle plugin, feel free to provide more details or open a ticket on Github)

When do I need the maven-compiler-plugin?

I understand that the maven-compiler plugin is used to compile the code. Some of my project does not have that plugin in the pom file? When is it required?
I am trying to answer my own question based on what I learned since posted this question. If this answer is correct or incorrect please comment. Thanks.
If this plugin is not defined, the Maven Super POM contains all the default plugins you will be using. It works fine for small and non-serious projects. However, the best practice is to define these plugins in a company-wise POM and so that when you upgrade maven, you would not end up using a different version of plugin.
Have a look at the Goals Overview Section in Apache Maven Compiler Plugin
The Compiler Plugin has two goals. Both are already bound to their proper phases within the Maven Lifecycle and are therefore, automatically executed during their respective phases.
You only have to add it if you want to change the default parameters

maven lifecycle configuration

I'm playing with maven plugins, specifically i'm trying to develop a custom maven plugin for eclipse. All goes well, it builds from console ... etc until:`
"Plugin execution not covered by lifecycle configuration"
appears. I research and find this:
http://wiki.eclipse.org/M2E_plugin_execution_not_covered;
obviously i do not want to ignore the plugin's execution, the execute instruction does not seem to work, as for the delegate to project configurator, i am not able to find
AbstractJavaProjectConfigurator.java.
I've searched in org.eclipse.jdt , core and source but there is no reference to what i am searching, best match i could find was here:
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt
All in one, what i want to achive is this: "Starting with m2e 1.1, maven plugin developers are able to provide lifecycle mapping metadata as part of the plugin itself." as stated in the first link i inserted. Any help would be greatly appreciated.
To simply bypass the mojo execution or telling m2e to simply execute your mojo via maven embedder you need the following:
a proper lifecycle mapping as explained in your link. Reference: https://github.com/php-maven/maven-php-plugin/blob/master/ide-plugins/eclipse/tags/2.0.3/org.phpmaven.eclipse.core/lifecycle-mapping-metadata.xml
However I put it in the root of the eclipse project to be able to debug it (finding those extra resources sometimes failes if you put them in src folders).
A build properties to embedd it into build: https://github.com/php-maven/maven-php-plugin/blob/master/ide-plugins/eclipse/tags/2.0.3/org.phpmaven.eclipse.core/build.properties
Activation via dependencies and extension:
Hope this helps. I was confused about the project configurator too. But the above example does not require any project configurator.

STS M2E 'Plugin execution not covered by lifecycle configuration" Error - Flex-Mojos

I am trying to write my pom.xml for a multimodal flex application. I have been using this resource as an example:
http://www.sonatype.com/books/mvnref-book/reference/flex-dev-sect-creating-with-archetype.html
I am using M2E v1.01 but I am faced with a number of 'Plugin execution not covered by lifecycle configuration" errors. As far as I can see - there are no m2E connectors available to resolve this and I have tried all the Maven advice I can find - to include:
Clean
Update dependencies
Update project configuration
The problem only occurs if the project is declared as swc or swf package. My next move to ask Eclipse to 'permanently mark goal as ignored' - which seems a little brash.
Any advice would be appreciated.
Thanks in advance.
With STS 2.8.0, we have upgraded m2eclipse to be version 1.0. However, this can cause a bit of trouble with existing projects. I wrote a blog on this a couple of months ago.
http://blog.springsource.org/2011/10/18/upgrading-maven-integration-for-springsource-tool-suite-2-8-0/
Essentially, the new architecture for m2eclipse requires that each maven plugin you use must be mapped to one Eclipse plugin to handle the plugin's execution inside of Eclipse. This obviously causes problems since not every maven plugin author has the knowledge or time to create also create and maintain an Eclipse plugin.
By marking the plugin as ignored, you are saying that the plugin should never be executed inside of Eclipse (implying that whenever you need it to be executed, you will do so from the command line). Once marked as ignored, you can then change it to execute, which means that it should always be executed whenever the associated lifecycle is performed in Eclipse. This may cause performance problems, and so only do it if you know the risks.
If all this is too much for you, then STS provides a downgrade option to revert to an older version of m2eclipse. Go to the Dashboard extensions page. Unfortunately, you will have to manually revert all changes to your .project and .classpath files (we provide an auto-upgrade mechanism, but not a downgrade mechanism...presumably everything is in version control).
Any questions or problems should be sent to the STS forums:
http://forum.springsource.org/forumdisplay.php?32-SpringSource-Tool-Suite
You can check this alpha connector "Flex Maven Integration for Flash Builder" on the eclipse marketplace: http://marketplace.eclipse.org/node/648556.

Resources