Error in pom.xml Maven build - eclipse

I am getting an error in my pom.xml when trying to build a maven project. The error is here on this plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
This is the error Eclipse shows:
Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.3.2:compile (execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not
be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-toolchain:jar:1.0:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-toolchain:pom:1.0 from http://repo.maven.apache.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-toolchain:pom:1.0 from/to central (http://
repo.maven.apache.org/maven2): The operation was cancelled.

Seems like the resolution failed.
Run mvn with the -U flag to disregard the cache and re-attempt resolution
(the alt+f5 dialog might help as well)

When I ran into this problem I figured out that it was due to a previous network problem. The local Maven repository avoids immediate reattempts. The best way to solve this was to use the eclipse "Update Maven Project" (ALT+F5) feature end check the option "Force Update of Snapshots/Releases".

This was not working for me , changing maven compiler version to 2.5.1 finally worked for me , hopefully this comes to rescue for anyone still struggling with this dependency
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

Update Maven Project by pressing (ALT+F5) and select the option "Force Update of Snapshots/Releases".

Update Maven Project by pressing (ALT+F5) and select the option "Force Update of Snapshots/Releases". works for me also

Got similar issue. Maven update and force update of snapshot didn't work for me.
Did following steps, issue resolved:
Remove project in eclipse.
Delete .Project file and . Settings folder.
Import project as existing maven project again to eclipse.

Related

Eclipse IDE import maven project error

I have a maven project which work with maven command (for example mvn install)
but when I try to import it into eclipse I got error /complaining about pom.xml
The error message from eclipse is :
Plugin execution not covered by lifecycle configuration: com.google.code.maven-replacer-plugin:replacer:1.5.3:replace (execution: default,
phase: process-sources)
Below is the snippet of pom.xml which eclipse complains
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>src/main/java/com/xyz/Version.java.template</file>
<outputFile>src/main/java/com/xyz/Version.java</outputFile>
<replacements>
<replacement>
<token>#buildtime#</token>
<value>${maven.build.timestamp}</value>
</replacement>
<replacement>
<token>#pomversion#</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
Any hints will be more than welcome!
Since you have shared incomplete pom , I am assuming , you do not have pluginManagement tag in your pom.xml.
Put your plugin blocks inside pluginManagement tag. E.g.:
<build>
<pluginManagement>
<plugins>
<plugin> ... </plugin>
<plugin> ... </plugin>
</plugins>
</pluginManagement>
</build>
The cause of this error is that Eclipse is unable to match some of the Maven build phases to its own build model, because Maven's is more sophisticated than Eclipse's (In this case, it is the process-sources phase, which some plugin is bound to).
But Eclipse offers a way to ignore this plugin, so that this error won't show up again. Open the POM and set the Overview tab. You should see the error message upside. Pass the mouse over and click on it. A popup must appear showing three options. You may chose between the last two:
Mark goal replace as ignored in pom.xml: If you click on this one, Eclipse will modify the POM file to add some declarations that will make Eclipse ignore this plugin.
Mark goal replace as ignored in Eclipse preferences: Though this one, Eclipse will modify its own configuration (Window > Preferences > Maven > Lifecycle Mappings) to ignore this plugin on every POM, from now on.

Plugin execution not covered by lifecycle configuration:org.apache.maven.plugins

environment:
Eclipse 4.4.2
Tomcat : 7
java 1.7
maven 3.5
STS packages installed.
This is my condition right now. when I made Spring legacy project(MVC) there was some problem in pom.xml.
First of all, Error occurred in war but after I clean the maven and update, the error was gone. but after that, the part of occurred the error. I don't know how to fix it.
But strangely I did this just like same on my other laptop yesterday, There wasn't any problem.
CentOS7
java 1.8
Eclipse 4.7.0
Tomcat 8.5.16
Here is the section of pom file
<plugin>
//plugin execution not covered by lifecycle configuration:org.apache.maven.plugins:maven-compiler-plugin2.5.1:testCompile(execution:default-testComplile, phase:test-conpile)").
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
Once done , try doing a Update Project by Right Click Project , Maven->Update Maven Project and select codebase and do check the Force Update of Snapshot/Release check box.
This will update your maven build and will surely remove your errors with pom.xml
Posting my solution, in case anyone else runs into a similar error. I had a very similar issue on a much later version of Eclipse, etc. No amount of Maven>Update Project solved it.
I ran manually ran "mvn clean install" from the command line, and it cleaned up the errors in eclipse.
Eclipse Neon
maven-compiler-plugin 3.8.1
You need to include the plugins in one of the life-cycles as pointed out by the error. If you want these plugins to be packed in the war file then enclose them in the <packaging></packaging>. But you will be needed to include that in a life cycle.

How to use SSH sampler with Maven JMeter Plugin

I'm sure other people tried this usage, but I could't find good examples online. I hope someone can help and comment whether it's doable at all.
Part of my pom.xml file is given below. The problem is that Maven couldn't find the "jmeter-ssh-sampler" declared as one dependency for "meter-maven-plugin". Should I configure Maven to search a different repositry for it ?
thanks
Yulin
[ERROR] Failed to execute goal com.lazerycode.jmeter:jmeter-maven-plugin:1.10.0:jmeter (jmeter-tests) on project jmeter-test: Execution jmeter-tests of goal com.lazerycode.jmeter:jmeter-maven-plugin:1.10.0:jmeter failed: Plugin com.lazerycode.jmeter:jmeter-maven-plugin:1.10.0 or one of its dependencies could not be resolved: Failure to find org.apache.jmeter.protocol.ssh.sampler:jmeter-ssh-sampler:jar:0.1.0 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<suppressJMeterOutput>false</suppressJMeterOutput>
<propertiesUser>
<host>${target_server}</host>
</propertiesUser>
<jmeterPlugins>
<plugin>
<groupId>org.apache.jmeter.protocol.ssh.sampler</groupId>
<artifactId>jmeter-ssh-sampler</artifactId>
</plugin>
</jmeterPlugins>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.51</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter.protocol.ssh.sampler</groupId>
<artifactId>jmeter-ssh-sampler</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
jmeter-ssh-sampler is not available in maven central:
http://search.maven.org/#search|ga|1|org.apache.jmeter.protocol.ssh.sampler
If this dependency can't be located, I don't think jmeter-maven-plugin will be able to make use of jmeter-ssh-sampler. It either needs to be made available in the repository maven is looking for, or you may end up with dirty hacks, which I'd suggest to avoid as much as possible (e.g. manipulate file system directly).
The JMeter SSH Sampler is not in any Maven repository. Most easy way to add it, clone the git repo, compile the code, and upload (deploy) the jar to your central Maven repository.

How to automatically generate lexer+parser with ANTLR4 and Maven?

I'am new to ANTLR4, and it seems that there is no Eclipse-Plug-In for v4. So it would nice to build automatically the Java sources from the .g4 grammars. I have a simple, empty Maven-project with src/main/java, src/test/java. Where to place the .g4 files? How can I automatically build the grammars with Maven?
My own POM-test failed:
<repository>
<id>mvn-public</id>
<name>MVNRepository</name>
<url>http://mvnrepository.com</url>
</repository>
...
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<goals>
<goal>antlr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Eclipse says:
Failure to find org.antlr:antlr4-maven-plugin:pom:4.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of
central has elapsed or updates are forced
I created the following Gist with a pom.xml designed solely for supporting automatic code generation from ANTLR 4 grammars during an Eclipse build. It includes the necessary lifecycle information for m2e to know that the code generation is necessary, and explicitly adds the code generation folder using the build-helper-maven-plugin since Eclipse seemed to have some trouble locating it otherwise.
In this configuration, grammar files (*.g4) are placed alongside the other Java source files. The Maven plugin will automatically add the proper package ... statement to the generated files, so you shouldn't include a #header{package ...} line in the grammar itself.
https://gist.github.com/sharwell/4979017
Check out this Antlr4 plugin for Eclipse
https://github.com/jknack/antlr4ide

How to configure maven install to skip tests in eclipse?

Is it possible to configure run as maven install in eclipse to skip unit tests? If so, how can it be done?
Ensure Maven is configured for your project
Right-click on your project
Go to 'Run As'
Select 'Run Configurations'
In the left-hand column, right-click 'Maven Build' and select 'New'
Select the base directory (the project) you want to build from
Write 'install' and any other goals you want in the 'Goals' field
Click the 'Skip Tests' radio button
Click Run!
accordig to maven's document you can write this in you pom.xml:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
It depends on maven test plugin that you use. You can try add parameter -Dmaven.test.skip=true to your build configuration.
You can put the property maven.test.skip in a profile in your pom. And then you activate this profile in eclipse in the project properties of maven in eclipse.
At the Run configurations there is a Maven Build type of Run configuration. At that you could set up the standard Maven skipTests parameter.
Putting this in my Pom.xml turned off the tests for me - but at maven build, not at maven install.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</plugin>