Maven plugin with eclipse - eclipse

I am trying to assemble Maven plugin with eclipse. For that I have already installed the m2eclipse. Now, in the new project, I have created a new Maven project.
When I try to run it by right clicking to the application, there are several options available.
When I run as Maven build, it gives build faliure but if I run as any other option such as maven install or maven clean or maven test, it gives build success.
Why so ?

On right click, when you do maven build, enter the command clean install and then try.

Related

Maven not displaying in Eclipse

Recently i have installed m2e maven container plugin in eclipse. After installing, i couldn't see Maven dependencies and maven options. when i select pom.xml and right click, there is no maven run option. i got XSL Transformation...how to remove this? I wnat to use maven targets . Also i couldn't select the existing maven project from source as there is no maven option is displaying.. please help me to fix this.
You can try to do right click on Project > Configure > Convert to Maven Project
After of that you will see maven options under Run As menu...
Or from your terminal you can try to convert you project:
cd ~/workspace/myProject/
mvn eclipse:eclipse

built and execute a maven-project in eclipse

I am trying to build and run a project using maven and under eclipse Kepler. I know that I shoud run (under linux using Terminal) the following commands to build and execute my project:
mvn clean install
mvn exec:java -Dexec.mainClass="com.example.App"
But I want to know, how to build and execute my project under eclipse.
In my eclipse, I have six commands at all: maven build, maven build..., maven clean, maven generate-sources, maven install and maven test.
How to built and execute my project on Eclipse?
well, the solution is as following:
right-click on pom.com -> you get many options-> you choose built->
enter in launch configuration: clean compile package -> click ok
After the build-process is finished, click on your application.java and click run (green button). That´s all

is it necessary to install testng plugin when testng dependency is added in maven project

I have selenium maven project in which the dependency for the testng is added. But i'm not able to see the run as TestNG in the "run" options. should i install testng plugin for eclipse
For eclipse, the plugin is required if you want to run as TestNG. The only other alternative to run tests from eclipse would be, if you have the maven plugin installed, then you can still trigger your tests by running as mvn test, but testng plugin would definitely simplify stuff.
If you are running from maven either from command line or from Jenkins, then plugin is not required.
If you are using Intellij Idea as IDE, then it will be available by default so don't need to even have it as dependency in maven but in case of eclipse you have to explicitly install it.

How to run maven project in eclipse

I have maven project on Java with TestNG. I want to run it from eclipse. I use Eclipse Kepler and have installed m2eclipse plugin. But there is no any option connected with maven in menu Run as... Could someone help me with such issue. How should I run maven project in eclipse?
To build a maven project in eclipse
In Eclipse, Run -> Run Configuration
Right click on Maven and select New
Enter Name, select base directory of your maven project
Enter Goal as "clean install"(or yours options)
Click on Apply and Run
There are some possible changes are there for build failure because of tool.jar not found and Reference here

Trying to understand how to work with Maven and Eclipse

I import a project into eclipse from svn and then go and run 'mvn install' from the command line and everything compiles fine. But I don't understand why the code is not compiled in Eclipse too.
From my previous experience I know that I need to go ahead in Eclipse and import "existing maven projects" to have Eclipse compile the code, I just don't understand why.
Thanks!
How have you imported the projects to Eclipse? By runnint mvn eclipse:eclipse to import them as 'Java project' or importing the maven projects directly with the m2eclipse plugin?
By default maven builds each project into a directory target in each project whereas Eclipse builds into eclipse-out. mvn install builds each maven project to create an archive (jar, war, ear etc) whereas Eclipse needs to build to be able to run the code in Eclipse.