maven: Plugin execution not covered by lifecycle configuration - eclipse

I use eclipse and have included following dependency in my pom.xml:
<dependency>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
</dependency>
When using this plugin:
<build>
<plugins>
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
I get this error within eclipse ide:
Plugin execution not covered by lifecycle configuration:
org.jboss.jandex:jandex-maven-plugin:1.0.7:jandex
(execution: make-index, phase: process-classes)
when clicking to "Discover new m2 connectors", I get the error:
No marketplace entries found to handle jandex-maven-plugin:1.0.7:jandex in Eclipse.
Please see Help for more information.
How can I solve this?
Solution:
Added <?m2e ignore?> in pom.xml:
<!-- https://www.eclipse.org/m2e/documentation/release-notes-17.html#new-syntax-for-specifying-lifecycle-mapping-metadata -->
<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version><dependency>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<!-- added: -->
<?m2e ignore?>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>

The Jandex plugin doesn't have a connector for Eclipse.
Just add an ignore rule. Eclipse will do that for you if you choose the right option and will add an ignore rule to your pom.xml.

Turns out1 that you should not ignore Jandex plugin in Eclipse. Otherwise your #QuarkusTests might fail with ArC/CDI errors.
I've created a PR adding the required m2e config to the plugin2. Once that is merged and released there should be no lifecycle issue anymore.
1 https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Jandex-Plugin.20in.20Eclipse.20m2e
2 https://github.com/wildfly/jandex-maven-plugin/pull/18

Looks like there is a updated Jandex version 1.0.8 that may have fixed this problem. I was referencing the quarkus documentation on a multi-module-maven which links to 1.0.7. I had a few issues running in quarkus:dev mode. Once I realized there was a 1.0.8 update, all my problems went away.

Related

Eclipse with ANTLR4 IDE add-on automatically builds with ANTLR 4.4

I'm trying to work on an ANTLR 4.9.2 project using Eclipse and Maven. I have configured my pom.xml to use the correct version of the runtime and build tools:
<properties>
<maven.compiler.target>18</maven.compiler.target>
<maven.compiler.source>18</maven.compiler.source>
<antlr4.plugin.version>4.9.2</antlr4.plugin.version>
<antlr4.version>4.9.2</antlr4.version>
</properties>
<dependencies>
<!-- ANTLR 4 parser runtime -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr4.version}</version>
</dependency>
<!-- ANTLR 4 parser generator tools -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.plugin.version}</version>
</dependency>
<!-- other irrelevant dependencies redacted -->
</dependencies>
<build>
<plugins>
<!-- build antlr4 grammars -->
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr4.plugin.version}</version>
<configuration>
<arguments>
<argument>-visitor</argument>
<!-- <argument>-Dlanguage=JavaScript</argument> -->
</arguments>
</configuration>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ensure antlr4 generated source is added to the build path -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/antlr4/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I have also installed the ANTLR4IDE eclipse add-on (reported as ANTLR 4 SDK 0.3.6.201611052310 antlr4ide.sdk.feature.group Edgar Espina in the Installation Details screen) in order to provide syntax highlighting when editing .g4 files.
The issue I have is that every time I modify a file, this appears in the console window:
ANTLR Tool v4.4 (C:\Users\user\AppData\Local\Temp\antlr-4.4-complete.jar)
KindModule.g4 -o C:\Users\user\git\kindtest3\target\generated-sources\antlr4\org\kindlang\kindtest3\grammar -listener -no-visitor -package org.kindlang.kindtest3.grammar -encoding UTF-8
BUILD SUCCESSFUL
Total time: 4 second(s)
and running the project tests fails with the error message ANTLR Tool version 4.4 used for code generation does not match the current runtime version 4.9.2
I have tried to disable the setting "Tool is activated" under "Project properties / ANTLR4 / Tool", but this only seems to disable it for the current session. When I restart Eclipse it starts happening again.
(Updated -- in fact, there seems to be a bug in the properties dialog: when I click "apply & close", a message box with the title "Error" is briefly displayed but then disappears before I can read its contents)
How can I permanently prevent this automatic build that is using the wrong version of ANTLR from running?
Unfortunately I can not say something about Eclipse.
I would suggest to use the antlr4-maven-plugin in the correct way like this:
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
<configuration>
<visitor>true</visitor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Furthermore the configuration to use build-helper-maven-plugin is simply superflous because the antlr4-maven-plugin correctly adds the information to be compiled. This means remove the whole configuration and definition for build-helper-maven-plugin because it is not needed at all.
Also I would suggest to upgrade to the most recent version of antlr4-maven-plugin / runtime which 4.11.1 at the moment...
I would check the compilation etc. on plain command line.
I have been able to solve the problem by directly editing the com.github.jknack.antlr4ide.Antlr4.prefs file in the .settings directory under my project root and changing the line autobuilding=true to autobuilding=false.

Maven auto-clean on package

I'm having some troubles trying to auto-clean each time i run mvn package.
I've added in the POM :
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
But i'm getting the following error from M2Eclipse :
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-clean-plugin:2.5:clean (execution: auto-clean, phase: initialize)
I've tried other phases like "validate" or "generate-resources" but i'm always getting the same error.
It's not a Maven problem, it's m2eclipse. I haven't used it in a long time, but apparently when you add some plugin executions, you have to add additional configuration to m2eclipse. There's a lengthy description of this error on the Eclipse wiki.

Plugin error: execution not covered by lifecycle configuration

I am trying to use the maven-warpath-plugin available here. But I keep getting an error in my pom.xml file that says:
Plugin execution not covered by lifecycle configuration: org.appfuse.plugins:maven-warpath-plugin:2.1.0:add-classes (execution: default, phase: generate-sources)
How do I resolve this? Here is my pom.xml snippet for the plugin:
<plugin>
<groupId>org.appfuse.plugins</groupId>
<artifactId>maven-warpath-plugin</artifactId>
<version>2.1.0</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>add-classes</goal>
</goals>
</execution>
</executions>
</plugin>
Eclipse offers me a quickfox tip to "discover new m2e connectors" to resolve this error. I have installed most of the connectors available that seem to apply but the error is still there. Any ideas how I could make this work?
This is the new behaviour of m2e (which replaced the old m2eclipse plugin). To specify what eclipse should do with the plugin you have to configure the build lifecycle mapping in the project's pom.xml - or install a connector (which decides if the plugin needs to be executed in an eclipse build or not) if it exists.
As there seems to be no connector for the maven-warpath-plugin yet you have to define the behaviour in the pom. You can use the second eclipse quickfix for this (Permamnently mark goal add-classes in pom.xml as ignored in eclipse build). This will add the following section to your pom:
<build>
......
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.appfuse.plugins
</groupId>
<artifactId>
maven-warpath-plugin
</artifactId>
<versionRange>
[2.1.0,)
</versionRange>
<goals>
<goal>add-classes</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
You can change the <ignore> action to <execute> if you want to process the plugin in each eclipse build (on import, clean, ...).
The plugin configuration is eclipse specific and does not make the pom.xml look nicer - but at least it has no influence on the Maven build....
Also see the answer How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds
Error pom.xml: Plugin execution not covered by lifecycle configuration: org.bsc.maven:maven-processor-plugin:3.3.3:process
my project is ProjectA, it's created by maven version 3.3.3 and i used eclipse version 4.5. But when install eclipse version 2021 - 4.20, then I open projectA on eclipse (version 4.20) errors appear in pom.xml: error detail: Plugin execution not covered by lifecycle configuration: org.bsc.maven:maven-processor-plugin:3.3.3:process (execution: process, phase: process-resources)
I don't know why appears on eclipse's new version 4.20. Error appear "execution"
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.3</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-resources</phase>
<configuration>
Thank you very much for help!

M2E and having maven generated source folders as eclipse source folders

I have a maven project in eclipse and have maven goals that run annotation processors to generate code. The output folder for this code is target/generated-sources/apt.
In order for Eclipse to see this generated code I need to add target/generated-sources/apt as a source folder to the Eclipse project.
However, this causes there to be an error of type "Maven Configuration Problem" saying
Project configuration is not up-to-date with pom.xml. Run project
configuration update
I think I understand why this is the case as Eclipse has a different set of source folders to Maven's set. But I need this different set, as I need Eclipse to be able to see the generated source folders...
When doing a pure Maven built, these source folders will be included in the build, by Maven.
BTW, I have upgraded to the official Eclipse release of the Maven Eclipse plugin, m2e 1.0 - what used to be m2eclipse. I'd like to see if I can find a work around/solution to this with the m2e plugin before I have to go back to the old m2eclipse version.
You need to attach the source directory with the build-helper-plugin.
Like so:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
You will also need to:
Install the "Apt M2E Connector" from the Eclipse Marketplace.
To do so click the error in the Overview tab of your pom.xml and select "Discover".
Ensure there are no plugin execution filters for the build-helper-maven-plugin (see https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html)
Right-click the Error message:
Project configuration is not up-to-date with pom.xml Run project
configuration update
in the Problems View and select Quick Fix and click Finish to select the default Update project configuration. This fixes it.
After switching to new versions of m2e/maven/apt,... i had builderrors because of the duplicated files, caused by the added buildpath by the buildhelper, so i needed to remove the "apt-generated"-Folders from the buildhelper.
To fix the Problem in Eclipse, not adding the "apt-generated"-folder via Update Maven Configuration in M2E, i've written a M2E Plugin to fix this problem. It adds the outputDirectories configured in the maven-apt-plugin to the buildpath of the Project.
https://apt-m2e.googlecode.com
In m2e 1.0 the handling of Maven plugins has changed. You might be lacking a specific m2e extension for your code generating plugin. Here is all the documentation I managed to find.
This bug report may also be relevant.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350081
request on CXF JIRA (see 1) to add lifecycle mappings in the cxf-codegen-plugin itself. This would require m2e 1.1 but I believe it is better approach than having connectors built outside of cxf project, assuming that lifecycle mapping API would change less frequently than cxf-codegen-plugin and cxf.
You can also use the buildhelper m2e connector available in the discovery catalog. I'm using Eclipse 3.7
Eclipse Java EE IDE for Web Developers.
Version: Juno Service Release 1
mvn archetype:generate \
-DarchetypeGroupId=org.codehaus.mojo \
-DarchetypeArtifactId=gwt-maven-plugin \
-DarchetypeVersion=2.5.0
mvn clean install
work perfectly.
But in eclipse I have the same error on Asinc class.
Just press F5 on project. Fix this problem.
This was what I found that worked good using spring 3.1.1 which does have the 3.0.6 version as well in it. Once I got the plugins setup and put into the correct area of the pom and included the argline and endorseddirs to have the java sources put out into the target/generated-sources/cxf folder then maven generated the sources ok.
....
<properties>...
<dependencyManagement>
<dependencies>.....
</dependencyManagement>
<dependencies>
<dependency>....
</dependencies>
<!-- *************************** Build process ************************************* -->
<build>
<finalName>eSurety</finalName>
<plugins>
<!-- Force Java 6 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Deployent on AS from console
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>${version.jboss.as.maven.plugin}</version>
</plugin>
-->
<!-- wildbill added tomcat plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<!-- Surefire plugin before 2.9 version is buggy. No need to declare here,
it's being referenced below w/ the version
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
-->
<!-- developer added these -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArguments>
<endorseddirs>target/generated-sources/cxf</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArguments>
<endorseddirs>target/generated-sources/cxf</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2</version>
</artifactItem>
</artifactItems>
<outputDirectory>target/generated-sources/cxf</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<!-- *********************** Profiles ************************************ -->
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be
used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization
your app will need. -->
<!-- By default that is to put the resulting archive into the
'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>projName</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>process-sources</id>
<phase>generate-sources</phase>
<configuration>
<fork>once</fork>
<additionalJvmArgs>-Djava.endorsed.dirs=target/generated-sources/cxf</additionalJvmArgs>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
<!-- Actual war created in default target dir -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
If your wsdl folder is in ${basedir}/src/main/resources it'll find it automatically
Hope this helps!
~wildbill
In case for some reason you can't use the build helper plugin the easiest way (albeit not as convenient and somewhat tedious) I have found to deal with this is:
Separate the generated source code into its own project or sub module.
You will want to keep this project predominately closed or not imported into Eclipse when you are working on the parent project.
In the parent project that needs the generated code make sure to now depend on the generated source code project via Maven pom dependency.
When you need to update the generated code go to the generated code project and run mvn install. Now refresh the parent project by right clicking and selecting Maven->Update Project...
This generally works well for projects that use a semi static source for code generation such as SOAP WSDLs (Apache CXF) or code generated from a database (jOOQ). For APT and other AspectJ-like-code it doesn't work as well because you are editing the source frequently.
For new visitors to this question -
build helper maven plugins and m2e connectors go hand in hand. Older versions
(before 2.0) of build helpers have moved into an eclipse archive link
build helper versions archived
Pick the correct link from the list and add it as an eclipse update site. It should ask you for a bunch (seriously.. a huge bunch ) of eclipse updates . Please accept and you are good to go.
the configuration to the build helper plugin did work for us.
but be aware, that the destination folder always has to be equal to the configuration of the plugin u're using for the annotation processing itself.
for example the maven-processor-plugin uses the target folder ${project.build.directory}/generated-sources/apt as default. if you wish another destination for your generated source files you can set it by the tag as shown below.
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<defaultOutputDirectory>apt_generated</defaultOutputDirectory>
<processors>
<processor>com.any.processor.invoker</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
Here is the solution
Open Marker View (Window > Show View
Right-click on the Error message
Select Quick Fix
Click Finish

Getting groovy, maven, and eclipse to play nice together?

So we have some unit tests written in groovy. We have the Groovy Eclipse plugin going, we have gmaven going, but the problem is that the maven eclipse plugin doesn't automatically add the src/test/groovy directory as a source directory. So, I enlisted the build-helper plugin to add a source directory, but then the problem becomes the source directory - in eclipse, the filters will include **/*.java and exclude everything else, which leads to the groovy eclipse plugin being confused. I've managed to jury-rig the problem by using the build helper to add-test-resource with the right .groovy file filter. Obviously the problem here is that is not usable if we decided to use groovy classes in the projects - the .groovy classes would be included in the .jar files.
How do I fix this?
I dumped gmaven in favor of the groovy-compiler-plugin, which does the groovy compiler weaving for you. With gmaven I wound up with too many weird compiler errors where stubs were missing, etc. You still need the builder-helper, and the Groovy Eclipse plugin helps in linking the source to the compiled classes, but this has worked flawlessly between working within eclipse and at the command line.
<properties>
<groovy.version>1.8.0</groovy.version>
<groovy.provider>1.7</groovy.provider>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<verbose>true</verbose>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>1.8.0-03</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.5.1</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
We have created m2eclipse integration for Groovy-Eclipse. First, you must install m2eclipse:
http://m2eclipse.sonatype.org/sites/m2e
Then you can install the Groovy-Eclipse integration, which you can get here:
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/
or here for Galileo:
http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.5/
Note that the m2eclipse integration is still beta and we appreciate feedback from users to see how well it works for them.
I happened to check out the maven eclipse plugin page and it turns out this type of problem is already solved:
http://maven.apache.org/plugins/maven-eclipse-plugin/examples/specifying-source-path-inclusions-and-exclusions.html
I ended up just using the build-helper-plugin to specify additional sources and added .groovy files to the source includes for the eclipse plugin.