Create Maven Project in Command Line VS in Eclipse - eclipse

I read in some tutorial , we can create Maven project in command line by
mvn archetype:generate
and then mvn eclipse:eclipse
and then Go to Eclipse and Import Existing Maven Project
Alternatively, I also see that we can create Maven project directly from Eclipse
In Eclipse : File - New - Maven Project ... Done
My questions
Why we need to create Maven project from command line if we can create it directly in Eclipse ?
Do we need to download Maven from here to create and use Maven project? I see Eclipse Neon 2 can create Maven project without downloading those jars.
Thank You.

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

How to import a maven project in eclipse?

I have a (command-line) maven based project which just works great (mvn clean, mvn verify, install all perfect)! I want now import this into eclipse not as maven project but regular eclipse project.
I did it but I have a dependency issue which I solved by just copying all the jars created into the .m2 folder to another folder into my eclipse workspace. Then I've added all these jars to my project.
everything ok!
Question is: I have the feeling that this is not the best way to manage the dependency in eclipse ... what do you suggest? best practices
If you have a simple java project which is made up of only one module, using Eclipse is very simple. To generate the Eclipse project files from your POM you execute the following command:
mvn eclipse:eclipse
If you have created or checked out the project with Eclipse, you only have to refresh the project in your workspace. Otherwise you have to import the project into your Eclipse workspace (From the menu bar, select File > Import > Existing Projects into Workspace). In the latter case the project (directory) should not be located in your workspace, because Eclipse might come into trouble, especially if you want to use Eclipse as the scm client.

How to add Maven dependencies in Eclipse libaries

Can any one explain how to add Maven dependency JAR i.e. build path libraries? To be very specific how to include JAR file mentioned in pom.xml to Java build path? Maven dependencies - unable to see jars over here.
Don't have a option to update Maven dependencies. Also executed the script mvn eclipse:eclipse, seen on StackOverflow.
Generally, you should not have any need to deal with such a task manually. Here is the correct procedure for importing of maven project to your Eclipse IDE:
Make sure you have m2eclipse plugin installed (Maven support for Eclipse). As far I remember it is included to Eclipse IDE for JEE developers by default.
Checkout your maven project to any directory
From this directory (root pom.xml is located in), run: mvn eclipse:eclipse
Go to Eclipse, File -> Import, select "Existing maven project"
Select directory where your root pom.xml is located, Eclipse should find all maven modules.
Optional: if eclipse will tell you that it can't recognize some maven plugins - ignore this, just continue.
If you follow this instruction, IDE will create all maven modules as eclipse projects and you will have an option to update maven dependencies and also willsee all of them rigth in IDE.

Creating a Mule project in Eclipse

I have started working with Mule. I am working with Mule Studio. This looks good.
But when I want to create a Mule project in Eclipse I am struck.
Please suggest me how I can create a Mule project in Eclipse.
Option 1: With Mule IDE Plugin for Eclipse.
You can use the Mule IDE plugin from eclipse. This helps in creating the mule project in eclipse.
To add plugins please start eclipse and navigate to help->install new software -> Add site and select the artifacts presented
Add muleide (mule plugin) - http://dist.muleforge.org/mule-ide/updates/3.4/
Then restart Eclipse after the plugin installation and You can create a Mule Project under the New Project option.
Option 2: Without Mule IDE. With Maven and Eclipse.
Open Command prompt.
Run the following Maven command to create a Mule project.
mvn org.mule.tools:mule-project-archetype:3.3.0:create -DartifactId=MySampleMuleProj -DmuleVersion=3.3.0
Then run the follwoing commands.
mvn clean compile
mvn eclipse:clean eclipse:eclipse
After this open Eclipse IDE
Import this project into the eclipse workspace.
Note: Use Import "Existing Maven Project" option for importing this project.
To run the Mule project in eclipse forllow the below steps.
1. Goto Run -> Run Configurations in eclipse and select Java Application.
2. Click on New launch configuration and enter name of the configuration(for ex. MyMuleProj).
3. Select MyMuleProj as a project and Main class "org.mule.MuleServer".
4. Click on Arguments tab and enter Program arguments "-config src/main/app/mule-config.xml".
You can see the Mule project up and Running.
:) Happy Learning.
You can import your existing project in eclipse or if you've a Maven project, create an Other project and select Maven-> Checkout Maven Projects from SCM or create a Java project. There are so many ways to do it.
I run my mule project in eclipse through MuleServer class and passing mule-config.xml as program argument.
Actually Mule Anypoint Studio is built on Eclipse. If you want to import any maven project, then do this : mvn clean compile
mvn eclipse:clean eclipse:eclipse

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.