Creating a Mule project in Eclipse - 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

Related

Create Maven Project in Command Line VS in 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.

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

How to deploy a maven project in tomcat within Eclipse

I have been trying to deploy a project that I created within eclipse but when I right click on the tomcat server and click "Add and Remove...", I got the message "There are no resources that can be added or removed from the server".
From what I understand it has something to do with the facets? I am not really sure to understand what is going wrong here.
Here is what I did for know:
I created a Maven project.
executed mvn eclipse:eclipse through the command line on the folder of the project
installed m2e
tried to add the project to the tomcat server
You probably want to use either mvn eclipse:eclipse OR m2e, but not both. m2e has gotten MUCH better in the last couple years, so that's what I would suggest.
Make sure you are using Eclipse for Java EE, otherwise you will need to install other plugins like WTP
Install m2e.
Install maven integration for wtp (from the eclipse marketplace)
make sure the artifact type for your project is war
Import Existing Maven Project in eclipse and browse to your pom to import the project.
It should give the correct facets to your project so it looks like a web project.

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.

Eclipse (STS) + Maven

I basically have 2 questions:
Is there a way to invoke maven console from eclipse? (where I could write eclipse:eclipse, and it started building eclipse project)
Where does STS unpack it's maven? I'd like to add that path to env variables, so that I could use it from my windows console.
Is there a way to invoke maven console from eclipse? (where I could write eclipse:eclipse, and it started building eclipse project)
You could open a shell inside eclipse , cd into the right directory and run the maven console from there. But, when using M2Eclipse (see next point), you're not supposed to run eclipse:eclipse.
Where does STS unpack it's maven? I'd like to add that path to env variables, so that I could use it from my windows console.
STS bundles M2Eclipse which comes with an embedded version of Maven (so it doesn't "unpack" Maven). But you can Configure M2Eclipse to use an external version. Go to window > Preference > Maven > Installations and Add... your external install:
Try the m2eclipse plugin from sonatype and you can eliminate use of 'mvn eclipse:eclipse' altogether. After installing m2eclipse and restarting eclipse, select File->Import->Maven->Existing Maven project. Browse to your maven project and select it. The m2eclipse plugin reads the pom and creates an eclipse project (this is the step that 'mvn eclipse:eclipse' gives). There are other useful features of the m2eclipse plugin including pom editor.
m2eclipse project is moving out of sonatype into the eclipse foundation project page and will be released on the Indigo train.
See this page for more info on m2eclipse: http://m2eclipse.sonatype.org/